Functions that contain sensitive information can use include (), include_once (), require (), and require_once () to insert this function library into the script, you can also use the PHP auto_prepend configuration command to automatically Insert Files.
From: http://www.cnblogs.com/tianxin2001x/archive/2010/01/20/1652163.html
If you want to use require () to add the header and footer to each page, there is another way. In the configuration filePHP. iniThere are two optionsAuto_prepend_fileAnd auto_append_file. With these two options, you can set the header and footer to ensure that they are loaded before and after each page. The files contained in these commands can be the same as those contained in the include () Statement; that is, if the file does not exist, a warning is generated.
For Windows, the settings are as follows:
Auto_prepend_file = " C:/program files/include/header. php "
Auto_append_file = " C:/program files/include/footer. php "
For UNIX, the settings are as follows:
Auto_prepend_file = " /Home/username/include/header. php "
Auto_append_file = " /Home/username/include/footer. php "
If you use these commands, you do not need to enter the include () statement, but the header and footer are no longer optional content on the page.
If you are using an Apache web server, you can modify different configuration options for a single directory. The premise is that the server allows you to reset its master configuration file. To set Automatic prefix and automatic append for a directory, you must create a file named. htaccess in this directory. This file must contain the following two lines:Code:
Php_value auto_prepend_file " /Home/username/include/header. php "
Php_value auto_append_file " /Home/username/include/footer. php "
Note that its syntax and configuration filePHP. iniThe corresponding options in are different, the same as the php_value at the beginning of the line: no equal sign. ManyPHP. iniYou can also modify the configuration settings in this way.
Set options in. htaccess insteadPHP. iniMedium
setting in the configuration file of the Web server brings great flexibility. It can be performed on a shared machine that only affects your directory. You do not need to restart the server and do not need administrator permissions.
use. one disadvantage of the htaccess method is that each file in the directory to be read and parsed must be processed each time, rather than only once at startup, so the performance will be reduced.