Learn PHP configuration files easily_PHP tutorial
After a long period of development of PHP, many users know PHP very well. Here I will express my personal understanding and discuss with you. 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 many semicolons "" in the PHP.INI file, just like Windows systems.
These semicolons are used to represent annotations. In other words, in order to make the PHP configuration file clear and easy to understand, the developer gives a brief description of each configuration function after the semicolon. These annotation lines will be 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 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 extraordinary times. 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 if I only need these functions for certain files? Use your brain. Let’s take an example of a PHP configuration file:
<ol class="dp-xml"> <li class="alt"><span><span>myprefix.php文件 </span></span></li> <li class=""> <span></span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=alt><SPAN>if (strstr(strtoupper( PHP_SELF),"/PHPTEST/")) </SPAN><LI class=""><SPAN>echo "我的广告!</SPAN><STRONG><FONT color=#006699><SPAN class=tag><</SPAN><SPAN class=tag-name>BR</SPAN><SPAN class=tag>></span></font></strong><span>"; </span> </li> <li class="alt"> <span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span> </li> </ol>
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 allow functions such as include() and require() to search for 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. PHP configuration files such as:
<ol class="dp-xml"> <li class="alt"><span><span>UNIX例:</span><span class="attribute"><font color="#ff0000">include_path</font></span><span>=.:/home/lib </span></span></li> <li class=""> <span>NT 例:</span><span class="attribute"><font color="#ff0000">include_path</font></span><span>=</span><span class="attribute-value"><font color="#0000ff">".:c:homeib"</font></span><span> 其中“.”表示当前目录。 </span> </li> <li class="alt"><span>gpc_order string </span></li> </ol>
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, priority Increasingly. 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, 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:
<ol class="dp-xml"> <li class="alt"><span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>form</SPAN><SPAN class=tag>></span></font></strong><span> </span></span></li> <li class=""> <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>input</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>type</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"Text"</FONT></SPAN><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>value</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>""</FONT></SPAN><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>name</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"a"</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span> </span> </li> <li class="alt"> <span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>input</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>type</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"Submit"</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span> </span> </li> <li class=""> <span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>form</SPAN><SPAN class=tag>></span></font></strong><span> </span> </li> <li class="alt"> <span></span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=""><SPAN>echo a; </SPAN><LI class=alt><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong><span> </span> </li> </ol>
Let's use the text when magic_quotes_gpc=on and off. Enter single quotes or double quotes into the box, 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 mails. Compared with Microsoft ASP, this function of PHP is much simpler and more convenient. Someone may ask, what should I do if I do not 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.
<ol class="dp-xml"> <li class="alt"><span><span>mysql.default_host string </span></span></li> <li class=""><span>mysql.default_user string </span></li> <li class="alt"><span>mysql.default_password string </span></li> </ol>
Readers who have used ODBC know that when setting up ODBC, you always need to set the database location and its default login user name and password. These parameters also mean the same, but they are used in MYSQL. That’s all. For the sake of security, we also need to make 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 needed 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.
<ol class="dp-xml"> <li class="alt"><span><span class="attribute"><font color="#ff0000">error_prepend_string</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">"<font color=ff0000>"</font></span><span> </span></span></li> <li class=""> <span></span><span class="attribute"><font color="#ff0000">error_append_string</font></span><span> = </span><span class="attribute-value"><font color="#0000ff">"</font>"</font></span><span> </span> </li> </ol>
这两个设置参数更有意思啦,按如上设置,那么我们一眼就能看到:我们的程序是否出错了!因为他的功能是把出错信息设置成显眼的红颜色了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
