Home >Backend Development >PHP Tutorial >Usage of php auto_prepend_file and auto_append_file

Usage of php auto_prepend_file and auto_append_file

WBOY
WBOYOriginal
2016-07-25 09:04:141103browse
  1. auto_prepend_file = "c:/Program Files/include/header.php"
  2. auto_append_file = "c:/Program Files/include/footer.php"
Copy the code

and set it like this in unix:

  1. auto_prepend_file = "/home/username/include/header.php"
  2. auto_append_file = "/home/username/include/footer.php"
Copy the code

If you use these instructions, then There is no need to enter the include() statement, but the header and footer are no longer optional content on the page. If you are using the Apache web server, you can modify different configuration options for a single directory. This assumes that the server allows resetting its main configuration file. To set up automatic prepending and automatic appending to a directory, you need to create a file named .htaccess in the directory. This file needs to contain the following two lines of code:

  1. php_value auto_prepend_file "/home/username/include/header.php"
  2. php_value auto_append_file "/home/username/include/footer.php"
Copy code

Note: The syntax is different from the corresponding option in the configuration file php.ini, and is the same as php_value at the beginning of the line: no equal sign. Many configuration settings in php.ini can also be modified in this way.

Setting options in .htaccess instead of php.ini or in the web server's configuration file will bring great flexibility. This can be done on a shared machine that only affects your directory. No server restart is required and no administrator rights are required. One disadvantage of using the .htaccess method is that every file in the directory that is read and parsed has to be processed every time, rather than just once at startup, so performance will be reduced.



Statement:
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