If you want to speed up your php pages with minimal trouble and maximum results, do this: Source: [Webcodingtech] Put this code in your main header or template file, before EVERYTHING, even doctype. <?php function print_gzipped_page() { global $HTTP_ACCEPT_ENCODING; if( headers_sent() ){ $encoding = false; }elseif( strpos($HTTP_ACCEPT_ENCODING, ‘x-gzip’) !== false ){ $encoding = ‘x-gzip’; [...]
Have you ever needed to change a background image based on the state or IP address the visitor comes from? Here is the fastest, easiest, and most effective WP Plugin for that. I was blown away with how fast I got what I needed. This uses the very awesome MaxMind GeoIP web service. WP GeoLocation [...]
So, I love the ethereal sense of awesome I get from CodeIgniter. It seems to cut out both the convolution (4 letter word) of CakePHP with excellent documentation, and slaughters RubyOnRails by installing to my server sans the brain damage and muscle memory of the command line. CodeIgniter doesn’t force me to use models, which [...]
photo credit: Vagabond Shutterbug If there are things you want to appear on every page of your website, built in CakePHP, you will want to use a layout. I generally use one layout for header, footer, search, and other static elements. You can use multiples, but most of the time you won’t need more than [...]
July 16 2010 by
Ryan Carter in
PHP |
This is extremely helpful when trying to figure out what is going on in your page. When troubleshooting or just trying to figure out what data is in that mysteriously finicky array, this is a charmer: Var_Dump the contents of an Array <?php $arr = array(); //start the array empty $arr[] = 1; // these [...]
July 15 2010 by
Ryan Carter in
PHP |
Is there an echo echo echo…in here? Echo, if you don’t know, is how you output stuff to the screen. Like this: <?php echo ‘Hello, how are you?’; ?> Echo is used heavily in any php program, and you can do goofy crazy things, like: <?php $firstname = ‘Ryan’; $lastname = ‘Coder’; echo ‘Hello ‘.$firstname.’ [...]
$this->set(’posts’,$this->Post->find(’all’)); Typically for an index action, like this (in the controller context): Location: /app/controllers/posts_controller.php <?php class PostsController extends AppController{ var $name = ‘Posts’; function index(){ $this->set(’posts’,$this->Post->find(’all’)); } } ?>