Dialysis PHP configuration file php. ini

Source: Internet
Author: User

Today, let's talk about some interesting content in the PHP. ini file.

The PHP. ini file is believed to be familiar to every PHP enthusiast. It was named PHP3.INI in the previous PHP version PHP3.0. Open it with NOTEPAD. Files are usually in the Windows directory of the operating system. As you can see, PHP. the INI file contains many semicolons (""). like Windows systems, these semicolons are used to indicate annotations. That is to say, to make the configuration file clear and easy to understand, the developer gives a brief description of each configuration function after the semicolon, these annotation lines are ignored during system processing. Of course, another benefit is that when the PHP system configuration changes, we can add or remove annotations to or from some rows, which is simple and simple.
.

Auto_prepend_file string can specify that a file is automatically parsed and executed before reading all PHP files. It can be any file such as PHP, ASP, and HTML (but image files may not work ), it is useful in special cases. For example, if you want to add an advertisement on each PHP page, and assume that you are developing a website and want all visitors to perform authentication before reading any PHP page, you can make your verification code a separate file, and set string to the file name here. Careful readers have asked: What if I only need these functions for some files? Use your brains. For example:

Myprefix. php file
<? Php
If (strstr (strtoupper (PHP_SELF), "/PHPTEST /"))
Echo "my ads! <BR> ";
?>

In this case, you only need to set auto_prepend_file = "myprefix. php", then all php files under the phptest directory will contain your ad header! It should also be noted that this file should be placed in the path indicated by include_path. Otherwise, errors may occur, which will be mentioned below.

Auto_append_file string is similar to the above function, but it is automatically added to the end of the PHP file, and does not work when the PHP program exits with exit. With this function, we can easily add the company address footer!

Include_path string is used to search for files in the PATH defined by the include () and require () functions. Is it a bit like the set path Command Used in the DOS era? This parameter can provide a list of paths. However, in UNIX, paths are separated by colons. In NT, semicolons are used, and the direction of the slash is also different. For example:
UNIX example: Export de_path =.:/home/lib
NT example: include_path = ".: c: homeib" where "." indicates the current directory.
Gpc_order string

GPC is the first letter of the GET, POST, and COOKIE variables. The order of GPC is the priority level for the system to process the three variables. The priority increases sequentially from left to right. The default value is GPC. When two or three variables with the same name are passed to the server, the system will sort the variables by priority and only read the variables with higher priority. For example, if it is set to "GP", the cookie is ignored and GET is replaced by POST when the access method is the same. Of course, in programming, we should try to avoid passing variables with the same name in different ways at the same time, otherwise the readability of the program will deteriorate, in addition, different output results may occur in different systems.

The magic_quotes_gpc boolean parameter determines the special characters contained in the GET/POST/COOKIE variables: single quotation marks, double quotation marks, and slashes, do you want to add the Escape Character backslash ("" commonly used in c)? In PHP databases and other systems, single quotes and other characters usually have special meanings. to distinguish them from real characters, we can set magic_quotes_gpc = on, in this way, if the variable we get from the user end contains single quotes, an escape character will be added before it. Then we can use the stripslashes (string str) function as needed ); (This function removes the backslash Escape Character "" from the string. If there are two backslashes in a row, remove one and leave one. If there is only one backslash, remove it directly .) To remove the Escape Character "", we can compare it:

<Form>
<Input type = "Text" value = "" name = "a">
<Input type = "Submit">
</Form>
<? Php
Echo;
?>

Let's enter single quotation marks and double quotation marks in the text box when magic_quotes_gpc = on and off respectively, and then submit them to see what is the difference?

SMTP string specifies the domain name or IP address of the mail sending server, so that we can send emails. Compared with Microsoft's ASP, PHP is much easier to use. Someone may ask, what if I don't have an email server? Simply fill in the email server of the local ISP. In fact, the mail sending and receiving server is like the post office in our real life. It can be sent at any post office, while the mail reception is at a fixed post office.

Mysql. default_host string
Mysql. default_user string
Mysql. default_password string

Readers who have used ODBC know that when setting ODBC, you always need to set the database and its default logon username and password. These parameters also mean that they are used in MYSQL. For the sake of security, we also need to limit the user's power in MYSQL. Do not be lazy and use "root! If you set these parameters for convenience, you can directly use the mysql_connect () function to connect to the database. Note that no parameters are required here!

You may be thinking, although this is very convenient and dangerous! Don't worry. These parameters are invalid in PHP security mode. Let's take a look at the security mode settings.

Safe mode boolean is not a WINDOWS 98 security mode. When the PHP system is in safe mode, we can control the behavior of PHP programs, at this time, the default Database Host, user name, password, and other settings of some databases such as MYSQL and INFOMIX are invalid, so illegal users cannot easily connect to the database. In security mode, safe_mode_allowed_env_vars string indicates the type of system environment variables that can be changed by the program, if it is set to safe_mode_allowed_env_vars = PHP _, the system environment variables with only PHP _ headers can be modified. For example, if you use putenv ("windir = UUU") in the program "); to modify the environment variables, the system will prompt a security mode protection error. In addition, the security mode imposes certain restrictions on the system Command system (), such as running only in the specified directory, which can protect system files.

The log_errors boolean parameter specifies whether to record the error information in the LOG document when a PHP program fails. In the NT System, if we set error_log = syslog at the same time, we can see the error message of PHP in the application log of the Event Viewer, this is helpful for testing a large system.
Error_prepend_string = "<font color = ff0000>"
Error_append_string = "</font>"

These two setting parameters are even more interesting. We can see at a glance whether our program has an error! Because his function is to set the error information to a highlighted red color.

As for many other options, some of them can be seen at a Glance. If you are interested, try it yourself!

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.