Thursday, January 10, 2008

Common PHP's directives for general behavior

In PHP, you can customize the PHP's directives in three levels:
  • global level: php.ini file
  • virtual host or directory level: httpd.conf or .htaccess
  • executing php script level: ini_set() function
There is a configuration directive scope attached to each parameter. Refer to the documentation of the directives for more details. In the php.ini file note that starting a line with a semicolon (";") comments it out, so PHP will not read it.

I make a list of commonly used configuration directives (parameters) that help to customize the behavior of PHP. I am not saying you have to change the value of the directives, this just mention the effect of setting the value specified. The directives here are only relevant to PHP's general behavior, not related to an specific extension.
  1. zend.ze1_compatibility_mode = on , allows PHP4 applications to run in version 5 without problems. =) Cool, isn't?
  2. short_open_tag = on , allow the following scape format:
  3. output_buffering = on , send all output of a script at once, after the script has been completed. It allows make changes to the HTTP header throughout the script. No more "Cannot add header information - headers already sent".
  4. implicit_flush = on , flush the content of the output buffer after each call to print() or echo(). Useful where the server requires an unusually long period of time to perform something, and you want to show status update to the user rather than just wait.
  5. max_execution_time = number , maximum amount of seconds that a PHP script can execute.
  6. max_input_time = number , seconds that a PHP script devotes to parsing request data. Important when you upload large files.
  7. error_reporting = E_ALL , reports ALL errors and warnings (level of error-reporting sensitivity). Check the manual for other values.
  8. display_errors = on , show the error from the level specified by error_reporting directive.
  9. log_errors = on , any error will be logged to a particular file or to the syslog specified by error_log directive.
  10. error_log = "file" , if log_errors is enabled, this directive specifies the message destination.
  11. register_globals = on , enable this is a security risk Make globally available any external variable of the type COOKIE, ENVIRONMENT, GET, POST, and SERVER without its type. For example, use $var instead of $_GET['var']
  12. post_max_size = #M , maximum Mbytes of data can be sent via POST to a PHP script.
  13. magic_quotes_gpc = on , all single and double quotes, backslashes, and null chars are automatically escaped with a backslash. Only valid for data transmitted via GET, POST, and COOKIE.
  14. include_path = ". ; path" , this path serves as the base path used by functions such as include(), require(), etc. Separate multiple directories with a semicolon (;)
  15. doc_root = "path", used only if it is not empty. Indicate the default from which all PHP scripts will be server.
  16. open_basedir = ''path" , set a base directory to which all file operations will be restricted.
  17. file_uploads = on , enable the file uploading feature.
  18. upload_tmp_dir = "path" , temporary directory where files are first uploaded to the server.
  19. upload_max_filesize = #M , maximum Mbytes of the size of the file being uploaded.
  20. extension_dir = "path" , tells the directory in which the loadable extensions (modules) reside. The default, "./", means the extensions are located in the same directory as the executing script.
  21. enable_dl = on, allows to load PHP extension at run time.
  22. extension = "file" , dynamically load a particular module. Make sure that the appropriate software is installed on the operative system.
I hope this summary can we useful.

Mr. Anderson

No comments: