(Preliminary note: There are seemingly many variants of this question already here, but they all seem to focus on the filesystem location of the physical PHP files themselves, not the web URL location of things, which is what I'm after.)
INTRO 1:
I have a small "website" with the following physical filesystem structure:
variable.php folder test.php (In other words, variable.php in the top-level, and test.php in the folder folder.)
Here are the file contents:
<?php //variable.php $basePath = dirname($_SERVER['SCRIPT_NAME']); ?> <?php //test.php include("../variables.php"); echo $basePath; ?> INTRO 2:
When developing this "website" locally, it is on this address:
http://localhost/~noob/test-website QUESTION:
The problem is that if I put http://localhost/~noob/test-website/folder/test.php into my browser, it prints out /~noob/test-website/folder/.
I want it to print out /~noob/test-website (the "web location" of variable.php). In other words, I want to have global access from all files, even ones deeper in the filesystem hierarchy, to /~noob/test-website. How do I accomplish this?
I obviously do not want to hardcode this path in. The reason is that when I upload it onto a production server, the location changes to something more sane like http://example.com/ (and I don't want to have to modify this hardcoded path after uploading to the server, hence this question of course).
/).