If you do not want to change the include_path directories (or you don’t have access to php.ini) you can still set the include_path value within your root .htaccess file.
Update/Create /doc_root/.htaccess
Unix/Linux Servers
php_value include_path "/path/to/include"
Windows Servers
php_value include_path "C:/path/to/include"
PHP
To call the include within PHP do the following:
require_once('file.php');
The file above is in /doc_root/include/file.php
Options
Multiple include directories
If you have multiple include directories you can chain them with the separator for your OS, : (*nix), ; (Windows).
php_value include_path "/path/to/include:/path/to/include2"
Call files outside include directory
You can also traverse your directory structure if you need to call a file that is outside of the include_path.
file.php in /doc_root/include/file.php
require_once('./include/file.php');
file.php in /doc_root/test/file.php
require_once('./test/file.php');
file.php in /test/file.php, Outside, up one level from /doc_root
require_once('../test/file.php');
Related Posts
Tags: htaccess, include_path, PHP






















Found it very useful….