Home > Backend Development > PHP Tutorial > PHP configuration file application example

PHP configuration file application example

WBOY
Release: 2016-07-25 08:54:17
Original
986 people have browsed it
  1. if (strstr(strtoupper( PHP_SELF),"/PHPTEST/"))
  2. echo "My ad!
    ";
  3. ?>
Copy code

 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 does 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. like: UNIX example: include_path=.:/home/lib NT example: include_path=".:c:homelib" 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 (which is the commonly used "" in C language) ? 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 "".

Compare:

  1. < ?php
  2. echo a;
  3. ?>
Copy the code

In the case of magic_quotes_gpc=on and off respectively, enter single quotes and double quotes in the text box, and then submit, 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, what should I do if I don’t have a mail server? ?It's very simple, just fill in the mail server of your local ISP. 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.

  1. error_prepend_string = ""
  2. error_append_string = ""
Copy code

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



Related labels:
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