PHP Learning Research-php.ini configuration file roaming

Source: Internet
Author: User

Generally you do not need to change the PHP settings, it usually works well according to the default configuration. But developers as PHP designers consider that users may occasionally need to tweak some of the functionality of the PHP language for specific applications. As a result, they display some PHP variables through a configuration file named PHP.ini. This profile allows users to adjust PHP multiple features, including setting file paths and directories, changing session and database parameters, and activating extended options (activating extensions).

Before we begin our introduction, we will briefly describe how the PHP configuration file is organized. One of the reasons the file is named PHP.ini is that it follows the common structure of the INI file in many Windows applications. It is an ASCII text file and is divided into parts of several different names, each of which includes various variables associated with it. Each section resembles the following structure:

[MySection]
variable="value"
anothervariable="anothervalue"

The names of the parts are enclosed in square brackets at the top, and then a pair of "variable names-values" for any number of them, each one on a separate line. As with regular PHP code requirements, variable names are case-sensitive and cannot contain spaces, and the value of a variable can be a number, a string, or a Brownian type (Boolean).

Each line, if preceded by a semicolon, indicates that the line is a comment statement. This also makes it very easy to allow or disallow PHP functionality. All you need to do is annotate the relevant statements without deleting them, and the statement will not be parsed by the system. This is especially handy when you want to reopen a feature over a period of time, because you don't need to delete the row in the configuration file.

For easy PHP identification, the php.ini file must either be placed in the current directory, either in the directory defined by the $PHPRC environment variable, or in the directory specified at compile time (the Windows Home directory for Windows PHP).

After changing the PHP configuration by modifying the php.ini file, you need to restart the Web server for the configuration change to take effect (this is, of course, in the case of using PHP through a Web server). For PHP command line usage patterns, the system reads the configuration file every time it comes to the PHP binaries.

This is the first stop for profile roaming and also a very important one: language interpreter-related options. The first line is the engine variable, which controls whether the PHP engine is "on" or "off". Shutting down the engine means that the embedded PHP code will not be parsed by the Web server. It's usually pointless to turn it off, so keep it open.

Engine = On

Short_open_tag Controls whether the parser recognizes abbreviated <?...? > logo, will be equivalent to the standard <?php ...? > logo. If you anticipate that a shorthand mark will conflict with another language, or if you want to use strict syntax rules for your PHP code, you can turn it off.

Short_open_tag = On

Typically, sessions, cookies, or HTTP file header data in a PHP script must be sent before the script produces any output. If this is not possible in your application, you can do so by allowing PHP to be called the output buffering feature, which is controlled by the output_buffering variable.

If you turn on output buffering,php, the results of the script will be stored in a special memory buffer area and sent out when explicitly instructed. In this way, you can even send special HTTP header and cookie data in the middle of the script or at the end of the script. Of course, this will result in a certain degree of script performance degradation.

Output_buffering = Off

You can also assign a value to the output_buffering variable to specify the buffer area size, for example:

Output_buffering = 2048

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.