Include php inside php using relative paths
-
One of my pages uses a custom script:
/wp-content/themes/currenttheme/chat.php
I want to include in the above php another one located in
/forum/chat/index.php
The index.php includes its own files and for integration reasons must not be moved.Not working:
include('/../../../forum/chat/index.php'); /* returns Error_1 */
$root = $_SERVER['DOCUMENT_ROOT']; include($root."/forum/chat/index.php"); /* returns Error_1 */
$path = getcwd(); $myfile = "/forum/chat/index.php"; include ($path.$myfile); /* returns Error_2 */
The errors:
Error_1Warning: require(D:/My Dropbox/xampp/htdocs/lib/custom.php) [function.require]: failed to open stream: No such file or directory in D:\My Dropbox\xampp\htdocs\forum\chat\index.php on line 17 Fatal error: require() [function.require]: Failed opening required 'D:/My Dropbox/xampp/htdocs/lib/custom.php' (include_path='.;\My Dropbox\xampp\php\PEAR') in D:\My Dropbox\xampp\htdocs\forum\chat\index.php on line 17
Error_2
Warning: include(D:\My Dropbox\xampp\htdocs\forum/forum/chat/index.php) [function.include]: failed to open stream: No such file or directory in D:\My Dropbox\xampp\htdocs\wp-content\themes\currenttheme\chat.php on line 24 Warning: include() [function.include]: Failed opening 'D:\My Dropbox\xampp\htdocs\forum/forum/chat/index.php' for inclusion (include_path='.;\My Dropbox\xampp\php\PEAR') in D:\My Dropbox\xampp\htdocs\wp-content\themes\currenttheme\chat.php on line 24
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Include php inside php using relative paths’ is closed to new replies.