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.