I am often tired of including configuration files in my scripts. Even if it is a single file it becomes important to include that file in our scripts otherwise we wont get the necessary variables set. Once when I started searching for a workaround for it, I found that we can configure it right in one place and say PHP take care of this headache.
Yes, We can do it.
1.Place all your configuration files in one folder in the server. Say "DOCUMENT_ROOT/config/lib"
2. Create a new file with a name preinclude.php
3. Declare or include (again include ) all your common variables, config files in this file.
4.In the DOCUMENT_ROOT folder create a .htaccess file
5. Write the following code in this:
# Code starts here
php_value auto_prepend_file "path to include directory/preinclude.php"
# Code ends here
We can include whichever file which we feel should be executed before each and every file execution here.
Monday, April 26, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment