PHP study: traveling through the PHP. INI configuration file

Source: Internet
Author: User
Generally, you do not need to change the PHP settings. it usually works well according to the default configuration. However, developers who are PHP designers consider that users may occasionally need to adjust some of the functions of the PHP language for specific exploitation programs. Therefore,

Generally, you do not need to change the PHP settings. it usually works well according to the default configuration. However, developers who are PHP designers consider that users may occasionally need to adjust some of the functions of the PHP language for specific exploitation programs. Therefore, they display some PHP variables in the configuration file named php. ini. This configuration file allows you to adjust multiple functions of PHP, including setting file paths and directories, changing sessions, database parameters, and activating extensions.

Before starting our preparations, we will briefly clarify the organization method of the PHP configuration file. One of the reasons for naming a file php. ini is that it complies with the common structure of ini files in many Windows exploitation programs. It is an ASCII text file and is divided into several parts with different names. each part contains variables related to it. Each part is similar to the following structure:

[MySection]

Variable = 'value'

Anothervariable = 'anothervalue'

The names of each part are enclosed in square brackets and placed on the top. then, a pair of "variable name-value" is displayed for any number of targets, each of which occupies a single unique row. Like a conventional PHP code request, the variable name is case-sensitive and cannot contain spaces. the variable value can be a number, string, or a brown (Boolean ).

If each line starts with a semicolon, it indicates that this line is a comment statement. This also makes it very simple to promise or disable PHP. You only need to comment out the coherent statement without deleting it, and the statement will not be parsed by the system. Especially when you look forward to re-opening a function after a period of time, because you do not need to delete this line in the configuration file.

PHP. the INI file must either be placed in the current directory, or in the directory defined by the $ PHPRC environment variable, or the directory specified during compilation (for Windows PHP, the Windows main directory ).

After changing the php configuration through the PHP. ini file, you need to restart the Web server to make the configuration change take effect (of course, this is when PHP is applied through the Web server ). For the PHP command line application mode, the system reads the configuration file every time the PHP binary program is involved.

This is the first and most important stop of configuration file travel: Language Description program coherence options. The first line is the engine variable, which will hold whether the PHP engine is "on" or "off ". The closed engine means that the embedded PHP code will not be parsed by the Web server. Usually it is meaningless to close it, so it is enabled.


 
Engine = On

Short_open_tag determines whether the parser recognizes the abbreviated Mark, equivalent to a scale Mark. If it is expected that the short Mark will conflict with other languages, or you want to adopt strict syntax rules for PHP code, you can close it.

Short_open_tag = On

Generally, session, cookie, or HTTP header data in a PHP script must be sent out before the script generates any output. If it is not possible in your application, you can achieve this goal by agreeing to PHP as the output buffering function, which is controlled by the output_buffering variable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.