Wednesday, September 14, 2016

What is “PHP’s Configuration Directives”?

What is “PHP’s Configuration Directives”?

The php.ini file is PHP’s global configuration file, much like httpd.conf is to Apache. This file underwent a fairly significant reorganization as of PHP 5.3.0; however, in both pre- and post-5.3 versions the file continues to be organized into twelve sections, including:
•  Language Options
•  Safe Mode
•  Syntax Highlighting
•  Miscellaneous
•  Resource Limits
•  Error Handling and Logging
•  Data Handling
•  Paths and Directories
•  File Uploads
•  Fopen Wrappers
•  Dynamic Extensions
•  Module Settings
The “PHP’s Configuration Directives” section that follows will introduce many of the directives found in the php.ini file. Later chapters will introduce module-specific directives as appropriate. Let’s first take a moment to review the php.inifile’s general syntactical characteristics. The php.ini file is a simple text file, consisting solely of comments and the directives and their corresponding values.
Here’s a sample snippet from the file:
;
; Allow the <? tag
;
short_open_tag = Off
Lines beginning with a semicolon are comments; the parameter short_open_tagis assigned the value Off. Exactly when changes take effect depends on how you install PHP. If PHP is installed as a CGI binary, the php.inifile is reread every time PHP is invoked,thus making changes instantaneous. If PHP is installed as an Apache module, php.iniis only read in once, when the Apache daemon is first tarted.
In this case, you must restart Apache for any of the changes to take effect. The Apache httpd.conf and .htaccess Files When PHP is running as an Apache module, you can modify many of the directives through either the httpd.conffile or the .htaccessfile. This is accomplished by prefixing directive/value assignment with one of the following keywords:
•  php_value: Sets the value of the specified directive.
•  php_flag: Sets the value of the specified Boolean directive.
•  php_admin_value: Sets the value of the specified directive. This differs from php_valuein that it cannot be used within an .htaccessfile and cannot be overridden within virtual hosts or .htaccess.
•  php_admin_flag: Sets the value of the specified directive. This differs from php_valuein that it cannot be used within an .htaccessfile and cannot be overridden within virtual hosts or .htaccess. or example, to disable the short tags directive and prevent others from overriding it, add the following line to your httpd.conffile:
php_admin_flag short_open_tag Off
Within the Executing Script The third, and most localized, means for manipulating PHP’s configuration variables is via the ini_set() function. For example, suppose you want to modify PHP’s maximum execution time for a given script. Just embed the following command into the top of the script:
ini_set('max_execution_time', '60');
Configuration Directive Scope
Can configuration directives be modified anywhere? The answer is no, for a variety of reasons, most of them security related. Each directive is assigned a scope, and the directive can be modified only within that scope. In total, there are four scopes:
•  PHP_INI_PERDIR: Directive can be modified within the php.ini, httpd.conf, or .htaccessfiles
•  PHP_INI_SYSTEM: Directive can be modified within the php.iniand httpd.conffiles
•  PHP_INI_USER: Directive can be modified within user scripts
•  PHP_INI_ALL: Directive can be modified anywhere
PHP’s Configuration Directives
The following sections introduce many of PHP’s core configuration directives. In addition to a general definition, each section includes the configuration directive’s scope and default value. Because you’ll probably spend the majority of your time working with these variables from within the php.ini file, the directives are introduced as they appear in this file.
Language Options
The directives located in this section determine some of the language’s most basic behaviour. You’ll definitely want to take a few moments to become acquainted with these configuration possibilities. Note that I am only highlighting some of the most commonly used directives. Please take some time to peruse your php.ini file for an overview of what other directives are at your disposal.
Caution Although the PHP documentation still refers to the default values associated with each directive, the reorganization of the php.ini file into two separate versions, php.ini-development for development purposes, and php.ini-production for production purposes, renders the meaning of “default” context-dependent. In other words, the default value of many directives found in the version of php.ini you choose will be set differently than the same value as defined in the other php.ini file. Therefore, in the interests of practicality, I am going to break from convention and identify the default value as that used within the php.ini-development file. engine = On | Off
Scope: PHP_INI_ALL; Default value: On
This parameter is responsible for determining 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
short_open_tag = On | Off
Scope: PHP_INI_ALL; Default value: Off
PHP script components are enclosed within escape syntax. There are four different escape formats,
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. Thus, a means for disabling this particular format has been provided. When short_open_tagis enabled (On), short tags are allowed; when disabled (Off), they are not. 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";
%>
If you’re coming from an ASP background and prefer to continue using this delimiter syntax, you can do so by enabling this tag.
precision = integer
Scope: PHP_INI_ALL; Default value: 14
PHP supports a wide variety of data types, including floating-point numbers. The precision parameter specifies the number of significant digits displayed in a floating-point number representation. Note that 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
               
There are many directory in php configuration so take one visit to php.ini file any try experiment yourself this can help to better grip on php. Plz. Don’t forget to subscribe and plz leave a suggestion to improve my eligibility as writer. I hope You Like This in many Way.


No comments:

Post a Comment