auto_prepend_file and auto_append_file_PHP tutorial in PHP

WBOY
Release: 2016-07-13 17:18:54
Original
888 people have browsed it

When developing PHP programs, we sometimes write the same code at the beginning and end of each PHP script. For example, we often need to open and close sessions or establish and close database connections in each PHP page. Good programmers often look for an easy way to avoid writing the same code.

In the PHP configuration file, there are two configuration items auto_prepend_file and auto_append_file. We can specify two different files for these two configuration items, so that the code in these two files can be executed on each PHP page respectively. Executed before and after execution ends. We can configure these two options in the PHP configuration file php.ini and also configure these two options in the .htaccess file. The specific method to choose depends on personal preference.
Since this configuration in PHP is relatively simple, I will only give a brief introduction:
1.auto_prepend_file——Specify the code to be executed before each PHP page is executed.
2.auto_append_file——Specify the code to be executed after each PHP page is executed.
The use of these two configuration items in PHP is very simple. Everyone can fully understand it after a simple experiment.
In fact, the functions of these two configuration items are equivalent to the require statement in PHP. Therefore, if you do not have to use this function, try not to use this function of PHP, because it will make the readability of our code very poor.
It’s just a simple little function. Because I encountered it, I simply made a record

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/621606.htmlTechArticleWhen developing PHP programs, we sometimes write the same at the beginning and end of each PHP script code. For example, we often need to open and close session or...
in each PHP page
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