Home > Backend Development > PHP Tutorial > Dialysis of PHP configuration file php.ini_PHP tutorial

Dialysis of PHP configuration file php.ini_PHP tutorial

WBOY
Release: 2016-07-21 16:05:22
Original
803 people have browsed it

Today, let’s talk about some interesting contents in the PHP.INI file.

I believe that every PHP enthusiast will be familiar with the PHP.INI file. In the previous version of PHP, PHP3.0, it was named PHP3.INI. Open it with NOTEPAD. The file is usually in the Windows directory of the operating system. Everyone has seen that there are a lot of semicolons "" in the PHP.INI file. Just like Windows systems, these semicolons are used to represent comments. That is to say, in order to make the configuration file clear and easy to understand, developers face each semicolon after the semicolon. The configuration function is briefly described, and these comment lines are ignored during system processing. Of course, another benefit is that when the PHP system configuration changes, we can just add or remove comments to certain lines, which is simple and convenient
.

auto_prepend_file string You can specify a file to automatically parse and execute before reading all php files. It can be any file such as PHP, ASP, HTML (but not image files), which is very useful in special circumstances. For example, if you want to add an advertisement to each PHP page, and if you are developing a website and want all visitors to authenticate before reading any PHP page, you can make your verification code into a separate file, and then Just set string to the file name here. Careful readers will ask: What should I do if I only need these functions for certain files? Use your brain. For example:

Myprefix.php file
if (strstr(strtoupper( PHP_SELF),"/PHPTEST/"))
echo "My ad!
";
?>

In this way, just set: auto_prepend_file=" myprefix.php", then all PHP files in the phptest directory will contain your advertising header! It should also be noted that this file should be placed in the path pointed to by include_path, otherwise an error may occur, which will be mentioned below.

 auto_append_file string has a similar function to the above, except that it is automatically added to the end of the PHP file, and it will not work when the PHP program exits with exit(). With this feature, we can easily add a footnote to our company address!

include_path string The function of this parameter is to let include(), require() and other functions to 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 the paths are separated by colons in UNIX and semicolons in NT, and the directions of the slashes are also different. For example:
UNIX example: include_path=.:/home/lib
NT example: include_path=".:c:homeib" where "." represents the current directory.
gpc_order string

GPC is the first letter of the three variables GET/POST/COOKIE. Its order reflects the priority of the system in processing the three variables. From left to right, the priority increases in sequence. The default setting is GPC, so that when any two or three variables with the same name are passed to the server, the system will sort them by priority and only read the variable with a higher priority. Another example is setting it to "GP" to ignore cookies and use POST instead of GET when the access methods are the same. Of course, we should try to avoid passing variables with the same name in different ways at the same time during the programming process, otherwise the readability of the program will become worse, and there may be different output results in systems with different configurations.

Magic_quotes_gpc boolean This parameter can determine the special characters contained in the three variables of GET/POST/COOKIE: single quotes, double quotes, slashes, and whether to add the escape character backslash (that is, in C language Commonly used "")? Because in systems such as PHP databases, characters such as single quotes usually have special meanings. In order to distinguish them from real characters, we can set magic_quotes_gpc=on, so that if there are single quotes in the variables we get from the user side, they will be added in front. escape character, and then we can use the function stripslashes(string str); as needed (this function can remove the backslash escape character "" in the string.If there are two consecutive backslashes, remove one and leave one. If there is only one backslash, just remove it. ) to remove the escape character "", we can compare:

 


 
 < ;input type="Submit">
 

  echo a; In the case of off, enter single quotes or double quotes in the text box, and then submit to see what the difference is?

SMTP string specifies the domain name or IP address of the email sending server, so that we can send letters. Compared with Microsoft ASP, this function of PHP is much simpler and more convenient. Someone wants to ask, if I don’t have How to configure a mail server? It's very simple, just fill in the local ISP's mail server. In fact, the mail-sending and receiving server is just like the post office in our real life. Mail can be sent at any post office, but mail is received 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 up ODBC, you always need to set the database location and its location. The default login username and password, these parameters also have the same meaning, but they are used in MYSQL. For the sake of security, we also need to set some restrictions on the user's rights in MYSQL. Don't be lazy and use "root"! If these parameters are set for convenience, then we can directly use the function mysql_connect() to connect to the database. Note that no parameters are required here!

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

Safe mode boolean This is not the safe mode of WINDOWS 98. When the PHP system is in safe mode, we can control the behavior of the PHP program to a certain extent. At this time, the default database host, user name, password and other settings of some databases such as MYSQL, INFOMIX, etc. are invalid, and illegal users cannot easily connect. database. And in safe mode, the safe_mode_allowed_env_vars string setting indicates what types of system environment variables can be changed by the program. If it is set to safe_mode_allowed_env_vars=PHP_, it means that only system environment variables starting with PHP_ can be modified. For example, if at this time in the program If you try to use putenv("windir=UUU"); to modify environment variables, the system will prompt a safe mode protection error. In addition, safe mode has certain restrictions on system commands such as system(), such as they can only be run in specified directories, etc. This can protect system files to a certain extent.

 log_errors boolean This parameter specifies whether the error information should be recorded in the LOG document when the PHP program errors. In the NT system, if we also set error_log =syslog, we can see the error information that occurred in PHP in the application log of the event viewer, which is helpful for testing a large system.
error_prepend_string = ""
error_append_string = "
"

These two setting parameters are more interesting. Set them as above, then we can see them at a glance See: Did our program go wrong! Because his function is to set the error message to a conspicuous red color.

As for many other options, some are obvious at a glance. If you are interested, try it yourself!


http://www.bkjia.com/PHPjc/315716.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315716.htmlTechArticleToday, let’s talk about some interesting contents in the PHP.INI file. I believe that every PHP enthusiast will be familiar with the PHP.INI file. In the previous version of PHP, PHP3.0, it was named PHP3.IN...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template