backsmith Posted December 13, 2012 Share Posted December 13, 2012 Hi This is aquestion about absolute and realative addressing across a web host and a local testing server. I have just upgraded to Dreamweaver CS6 and want to use the php testing server. Previously I was just uploading everything and testing on the remote host. Problem is that I use lots of includes in my pages. Content is in a directory tree. This is an example. Content/conditions/back_pain/muscles.php which looks like THIS <?php include("/home/linweb15/b/mysite.co.uk-10629534829/user/htdocs/externals/main.php" );?> Thats the whole page. I use the full path because I use the same main.php to set out the layout for all the pages and a relative link fell down and I dont want to use a differnt relative path in each php file.. Then in the included main.php I have this function. function curPageName() { return "content/".substr(substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1),0,-4).".htm"; } Any in the middle of the page I put I use <?php include( '/home/linweb15/b/mysite.co.uk-10629534829/user/htdocs/'.curPageName() ); ?> which drops in the text from "content/muscles.php" All works fine on the remote web host. BUT These long file paths are no use on my testing server which is at c:xampp/htdocs/mysite I think I need to use a variable set to the first part of the file path and for this to be different on the host and the testing server. eg /home/linweb15/b/mysite.co.uk-10629534829/user/htdocs/ or c:xampp/htdocs/mysite At last the question..... How is this best done? Thanks John Quote Link to comment https://forums.phpfreaks.com/topic/271975-help-with-includes-on-testing-server/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2012 Share Posted December 13, 2012 $_SERVER['DOCUMENT_ROOT'] Quote Link to comment https://forums.phpfreaks.com/topic/271975-help-with-includes-on-testing-server/#findComment-1399271 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.