Searching...
Thursday 6 June 2013

PHP’s CONFIGURATION DIRECTIVES - Part 1


PHP’s CONFIGURATION DIRECTIVES

The directives are introduced as they appear in php.ini file. This might be boring, but it's needed so read it carefully. Have it your way!!!

Note:-  Error Handling and Logging and File Uploads directives are not discussed  here as per your comfort. I will be introducing them on the go.

LANGUAGE OPTIONS

The directives located in this section determine some of the language’s most basic behavior. I am only highlighting some of the most commonly used directives.

engine = On | Off
Scope: PHP_INI_ALL; Default value: On

This parameter determines whether the PHP engine is available. Turning it off prevents you from using PHP at all. Obviously, you should leave this enabled if you plan to use PHP.

zend.ze1_compatibility_mode = On | Off
Scope: PHP_INI_ALL; Default value: Off

The zend.ze1_compatibility_mode directive attempts to revert several of these changes in PHP 5, raising the possibility that PHP 4 applications can continue to run without change in version 5. But it never worked as intended and was removed in PHP 5.3.0.

short_open_tag = On | Off
Scope: PHP_INI_ALL; Default value: Off

There are four different escape formats in PHP, the shortest of which is known as short open tags, which looks like this:


<?
echo "Some PHP statement";
?>

You may recognize that this syntax is shared with XML, which could cause issues in certain environments hence disabling option has been provided. It can be on(enabled) or off(disabled). Suit yourself.

asp_tags = On | Off
Scope: PHP_INI_ALL; Default value: Off

PHP supports ASP-style script delimiters, which look like this:


<%
echo "Some PHP statement";
%>

This escape format was adopted from asp and could be enabled by the users having some history in asp to feel familiar.

precision = integer
Scope: PHP_INI_ALL; Default value: 14

PHP supports a wide variety of datatypes, including floating-point numbers. The precision parameter specifies the number of significant digits displayed in a floating-point number representation. 
This value is set to 12 digits on Win32 systems and to 14 digits on Linux.

y2k_compliance = On | Off
Scope: PHP_INI_ALL; Default value: On

If for some bizarre reason you’re sure that a number of your site’s users may be using wildly outdated, non compliant browsers, then disable the y2k_compliance parameter; otherwise, it should be enabled.

output_buffering = On | Off | integer
Scope: PHP_INI_SYSTEM; Default value: 4096

Anybody with even minimal PHP experience is likely quite familiar with the following two messages:"Cannot add header information – headers already sent""Oops, php_set_cookie called after header has been sent"

Most commonly they are the result of the programmer attempting to send a cookie to the user after some output has already been sent back to the browser, which is impossible to accomplish because the header (not seen by the user, but used by the browser) will always precede that output. When enabled, output buffering tells PHP to send all output at once, after the script has been completed. This way, any subsequent changes to the header can be made throughout the script  because it hasn’t yet been sent. Enabling the output_buffering directive turns output buffering on. Alternatively, you can limit the size of the output buffer (thereby implicitly enabling output buffering) by setting it to the maximum number of bytes you’d like this buffer to contain. If you do not plan to use output buffering, you should disable this directive because it will hinder performance slightly. Of course, the easiest solution to the header issue is simply to pass the information before any other content whenever possible.

output_handler = string
Scope: PHP_INI_ALL; Default value: NULL

This interesting directive tells PHP to pass all output through a function(more about functions in php) before returning it to the requesting user. For example, suppose you want to compress all output before returning it to the browser, a feature supported by all mainstream HTTP/1.1-compliant browsers. You can assign output_handler like so:

output_handler = "ob_gzhandler"

ob_gzhandler() is PHP’s compression-handler function, located in PHP’s output control library. Keep in mind that you cannot simultaneously set output_handler to ob_gzhandler() and enable zlib.output_compression (discussed next).

zlib.output_compression = On | Off | integer
Scope: PHP_INI_SYSTEM; Default value: Off

This HTTP/1.1 feature is supported by most modern browsers and can be safely used in most applications. You enable automatic output compression by setting zlib.output_compression to On. In addition, you can simultaneously enable output compression and set a compression buffer size (in bytes) by assigning zlib.output_compression an integer value.
Compressing output before it is returned to the browser can save bandwidth and time. 

zlib.output_handler = string
Scope: PHP_INI_SYSTEM; Default value: NULL

The zlib.output_handler specifies a particular compression library if the zlib library is not available.

implicit_flush = On | Off
Scope: PHP_INI_SYSTEM; Default value: Off

Enabling implicit_flush results in automatically clearing, or flushing, the output buffer of its contents after each call to print() or echo(), and completing each embedded HTML block. This might be useful in an instance where the server requires an unusually long period of time to compile results or perform certain calculations. In such cases, you can use this feature to output status updates to the user rather than just wait until the server completes the procedure.

unserialize_callback_func = integer
Scope: PHP_INI_ALL; Default value: 100

This directive allows you to control the response of the un-serializer when a request is made to instantiate an undefined class. For most users, this directive is irrelevant because PHP already outputs a warning in such instances if PHP’s error reporting is tuned to the appropriate level.

serialize_precision = integer
Scope: PHP_INI_ALL; Default value: 100

The serialize_precision directive determines the number of digits stored after the floating point when doubles and floats are serialized. Setting this to an appropriate value ensures that the precision is not potentially lost when the numbers are later un-serialized.

allow_call_time_pass_reference = On | Off
Scope: PHP_INI_SYSTEM; Default value: Off

Function arguments can be passed in two ways: by value and by reference. It can be specified in the function definition, which is the recommended means for doing so. However, you can force all arguments to be passed by reference at function call time by enabling allow_call_time_pass_reference.


0 comments:

Post a Comment

 
Back to top!