About This Refcard
PHP is the world's most popular server-side Web scripting language, sporting a syntax simple enough to attract novice programmers yet powerful enough to run some of the world's most popular websites, among them Yahoo!, Facebook, GameSpy, and Vimeo.
This reference card was created to help you quickly navigate some of PHP's most commonplace features, including objectoriented programming, array and string manipulation, regular expressions, and MySQL integration.
PHP's behavior can be configured at a variety of levels:
Global Configuration
The php.ini file is PHP's configuration fi le, containing more than 200 directives capable of tweaking nearly every aspect of the language's behavior. This fi le is parsed every time PHP is invoked, which for the server module version occurs only when the web server starts, and every time for the CGI version.
Host- and Directory-specific Configuration
If you lack access to the php.ini fi le, you may be able to change desired directives within Apache's httpd.conf or .htaccess files. For instance, to force the display of all PHP errors for solely your development domain (for instance http://dev.wjgilmore.com), add the following to a .htaccess file:
php_fl ag display_errors on
Each directive is assigned one of three permission levels (PHP_INI_ALL, PHP_INI_PER_DIR, PHP_ INI_SYSTEM) which determines where it can be set. Be sure to consult the PHP documentation before tweaking settings outside of the php.ini fi le. See http://www.php.net/ini for a complete list of directives.
Script-specific Configuration Occasionally you'll want to tweak directives on a per-script basis. For instance to change PHP's maximum allowable execution time for a script tasked with uploading large fi les, you could call the ini_set() function from within your PHP script like so:
ini_set('max_execution_time', 60);
Changing the PHP File Extension
PHP's default fi le extension is .php, however you can change it to whatever you please by adding the desired extension to the AddType directive within Apache's httpd.conf fi le. For instance to configure Apache to recognize .dzone as a supported PHP file extension:
AddType application/x-httpd-php .php .dzone