Today, let's regaling some interesting content in the php.ini file.
Php. The INI file is believed to be familiar to every PHP enthusiast and is named Php3.ini in the previous version of PHP PHP3.0. Open it in Notepad, and the file is usually in the Windows directory of the operating system. As you can see, PHP. INI file contains a lot of semicolons "", like Windows systems, these semicolons are used to represent annotations, which means that for the configuration file to be clearly understood, the developer makes a short description of each configuration feature after the semicolon, and ignores the annotation lines when processing the system. Of course, another advantage is that when the PHP system configuration changes, we can add or remove some of the comments on the line, simple and convenient.
Auto_prepend_file string can specify that a file is automatically parsed before reading all the PHP files, and can be useful for any file (but not the image file) for PHP, ASP, HTML, and so on. For example, if you want to add an ad to each PHP page and assume that you are developing a Web site that will allow all visitors to authenticate before reading any PHP page, you can make your validation code a separate file, and then set string to that file name. The attentive reader asks: If I just need these features for some files, how can I do it, use my head, for example:
myprefix.php file
<?php
if (Strstr (Strtoupper (php_self), "/phptest/"))
echo "My ad! <BR> ";
?>
So as long as the setting: Auto_prepend_file= "myprefix.php", then all the phptest directory of PHP files will contain your ad head! It also needs to be explained that the file should be placed in the path indicated by include_path, or else it may be wrong, and it will be mentioned below.
The Auto_append_file string is similar to the above function, but is automatically added to the end of the PHP file, and the PHP program uses exit () to quit when it doesn't work. With this feature, we can easily add a footnote to the company's address!
The function of the include_path string is to have functions such as include (), require () find files in the path defined here, is it a bit like the set path command used in the DOS era? This parameter can provide a list of paths, but in Unix the paths are separated by colons, with semicolons in NT and the slashes in different directions. Such as:
UNIX Example: include_path=.:/ Home/lib
NT Example: include_path= ".: C:\home\lib". " Represents the current directory.
Gpc_order string
GPC is the first letter of the Get/post/cookie three variables, and its order reflects the priority of the system in handling three variables, from left to right, and the priority increments. The default setting is GPC so that when any of the two or three names of the same variable is passed to the server, the system is sorted by priority and only the higher-priority variables are read. Another example is a "GP" that ignores cookies and replaces get by POST with the Access method (methods). Of course, we should try to avoid passing the same variable in different ways at the same time, otherwise the readability of the program will be bad, and there may be different output in the configuration of different systems.
MAGIC_QUOTES_GPC Boolean This parameter determines the special characters contained in the three variables of Get/post/cookie: single quotes, double quotes, slashes, and the escape character backslash (which is commonly used in the C language)? Because in the PHP database and other systems, single quotes and other characters usually have special meaning, in order to distinguish with the real character, we can set magic_quotes_gpc=on, so that if we get from the user side of the variable in single quotes, we will precede the escape character, We can then use the function stripslashes (string str) as needed, which removes the backslash escape character "\" in the string. If two consecutive backslash, then remove one, leaving one. If there is only one backslash, remove it directly. To remove the escape character "\", we can compare:
Let's enter single and double quotes in the text box, respectively, in the case of Magic_quotes_gpc=on and off, and then submit to see what the difference is?
SMTP string Specifies the domain name or IP address of the mail sending server, so that we can send a letter, compared to Microsoft's ASP, PHP This function is much more convenient, someone to ask, if I do not have a mail server to do? Simply fill in the local ISP's mail server. In fact, the mail server is like our real life in the post office, in which the post office can send letters, and the letter is in the fixed post office.
ODBC readers know that when you set up ODBC, you always need to set the database and its default login username and password, which means that it is only used in MySQL. In order to be safe, we also need to be in MySQL in the user's power to do some restrictions, do not lazy use of "root" Ah! If these parameters are set for convenience, then we can connect to the database directly with the function mysql_connect (), and note that there is no argument here!
Everyone may be thinking, although this is very convenient, but also very dangerous! Don't worry, these parameters are not valid in PHP security mode, let's look at the security mode settings.
Safe Mode Boolean This is not a security mode for Windows 98. When the PHP system is in Safe mode, we can control the behavior of the PHP program, some databases such as MySQL, Infomix, such as the default database host, user name, password and other settings are invalid, illegal users can not easily connect to the database. And in Safe mode Safe_mode_allowed_env_vars string This setting indicates what type of system environment variable can be changed by the program, and if set to safe_mode_allowed_env_vars=php_ it means only php_ The leading system environment variable can be modified, for example, if you attempt to use Putenv ("windir=uuu") in your program, to modify the environment variable, the system prompts for a safe Mode protection error. Also, the security mode has certain restrictions on system command systems (), such as only in the specified directory to run, so that the system files can have a certain protective effect.
Log_errors Boolean This parameter specifies whether the error message should be recorded in the log document when the PHP program fails. If we set up Error_log =syslog at the same time in the NT system, we can see the error message in the Application log of the Event Viewer, which is helpful for testing a large system.
error_prepend_string = "<font color=ff0000>"
error_append_string = "</font>"
These two setting parameters are more interesting, as set, then we can see at a glance: Our program is not a mistake! Because his function is to set the error message into a conspicuous red color.
As for many other options, some look at the know, interested everyone to try it!
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.