Bakes Posted May 8, 2009 Share Posted May 8, 2009 Ok, my php page includes a file, which includes a second file. The second file provides the navigation bar of the first file. Now, the navigation bar uses ' $_SERVER["PHP_SELF"];' to determine what page it's on, to determine what page, and as such what links to use. Unfortunately, this uses the included file rather than the main file. How would I get the current url of the main page, rather than the included page? Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 8, 2009 Share Posted May 8, 2009 Use __FILE__ http://www.php.net/manual/en/language.constants.predefined.php Edit: Whoops, that will give you the same thing. Use this. $_SERVER['REQUEST_URI'] Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 8, 2009 Share Posted May 8, 2009 You are apparently including files using their URL instead of the file system path. You should be including local files using their file system path (for several good reasons), in which case $_SERVER["PHP_SELF"] would be the correct value. Quote Link to comment Share on other sites More sharing options...
Bakes Posted May 8, 2009 Author Share Posted May 8, 2009 This is correct. The reason I am doing this, is because they are hosted on different webservers, for reasons I don't want to go into. I have replaced $_SERVER["PHP_SELF"] in the first included file with the true path, but I cannot do this for the banner because it changes for different pages. So, how would I pass the var between the first included page and its banner? Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 9, 2009 Share Posted May 9, 2009 This will give you the page that was called by the browser - i.e. not the current page if it was included - $_SERVER['REQUEST_URI'] Quote Link to comment 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.