Auto_prepend_file and auto_append_file in PHP

Source: Internet
Author: User

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 on every PHP page or establish and close database connections. Good programmers usually look for a simple 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, let the code in these two files be executed before and after each PHP page is executed respectively. We can configure these two options in the PHP configuration file php. ini, or in the. htaccess file. The specific method is based on your preferences. This configuration in PHP is relatively simple, so I will only give a brief introduction: 1. auto_prepend_file -- specifies the code to be executed before each PHP page is executed. 2. auto_append_file -- specifies the code to be executed after each PHP page is executed. The use of these two configuration items in PHP is very simple. You will be able to fully understand it in a simple experiment. In fact, 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 our code very readable. It's just a simple small function. As a result, we can simply record it.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.