kalster Posted November 29, 2012 Share Posted November 29, 2012 i have main.php at root, and header.php at include/header.php. how to include main.php within the header.php. from within the header.php file when i try to include the main.php file like this, include "../main.php", i get an error that the file cannot be found. when i try to include the main.php like like this, include "./main.php" it works but my other included files within the same root as header cannot find main.php. this is strange. thank you in advanced. Quote Link to comment https://forums.phpfreaks.com/topic/271329-how-do-i-go-back-to-root-to-include-my-files/ Share on other sites More sharing options...
kalster Posted November 29, 2012 Author Share Posted November 29, 2012 update, i have tried to include ($_SERVER['DOCUMENT_ROOT'] ."index.php" .. my file at root but it is not working. what am i doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/271329-how-do-i-go-back-to-root-to-include-my-files/#findComment-1396093 Share on other sites More sharing options...
requinix Posted November 29, 2012 Share Posted November 29, 2012 The DOCUMENT_ROOT doesn't include a trailing slash. IIRC never does. include ($_SERVER['DOCUMENT_ROOT'] . "/index.php"); Quote Link to comment https://forums.phpfreaks.com/topic/271329-how-do-i-go-back-to-root-to-include-my-files/#findComment-1396109 Share on other sites More sharing options...
kalster Posted November 30, 2012 Author Share Posted November 30, 2012 thank you Quote Link to comment https://forums.phpfreaks.com/topic/271329-how-do-i-go-back-to-root-to-include-my-files/#findComment-1396319 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.