How to Use auto_prepend_file and auto_append_file, auto_append_file

Source: Internet
Author: User
Tags php website

How to Use auto_prepend_file and auto_append_file, auto_append_file

How to Use auto_prepend_file and auto_append_file

To send the file require to the top and bottom of all pages.


Method 1:Add the require statement at the top and bottom of all pages.

For example:

Require ('header. php'); page content require ('footer. php ');
However, if you need to modify the require file path at the top or bottom of the page, you need to modify all the page files. In addition, it is troublesome to add the require statement to each page.


Method 2:Use auto_prepend_file and auto_append_file to specify the require file at the top and bottom of all pages.

Php. ini contains two items:

Auto_prepend_fileLoad files at the top of the page

Auto_append_fileLoad files at the bottom of the page

To use this method, you do not need to change any pages. to modify the require file at the top or bottom, you only need to modify the values of auto_prepend_file and auto_append_file.


For example, modify php. ini and the values of auto_prepend_file and auto_append_file.

auto_prepend_file = "/home/fdipzone/header.php"auto_append_file = "/home/fdipzone/footer.php"
Restart the server after modification, so that the top and bottom of all pages will be require/home/fdipzone/header. php and/home/fdipzone/footer. php


Note: auto_prepend_file and auto_append_file can only require one PHP file, but this PHP file can require multiple other PHP files.


If you do not need all the pages to be on the top or bottom of the require file, you can specify a page file in a folder to call auto_prepend_file and auto_append_file

Add the. htaccess file to the folder that needs to load files at the top or bottom. The content is as follows:

php_value auto_prepend_file "/home/fdipzone/header.php"php_value auto_append_file "/home/fdipzone/footer.php"

In this way, the page files in the specified. htaccess folder will load/home/fdipzone/header. php and/home/fdipzone/footer. php. Other page files will not be affected.

Use. htaccess settings are flexible. You do not need to restart the server or administrator permissions. The only drawback is that each file read and interpreted in the directory must be processed each time, instead of processing it once at startup, the performance will be reduced.



How does php make a single directory automatically load files?

Windows is the same, but you need to enable. htaccess support.

Ubuntu server php website browsing Chinese garbled code how to solve

In php. ini, there is a configuration named auto_prepend_file = and auto_append_file =. You can understand what I mean, and write a file for unified processing. Let's just give me some extra points. In addition, it is best to use functions of the mb Series for encoding and conversion in Chinese.

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.