Hi everyone thanks for the great replies. After researching and trying more, I realized that php5 protects against 'cross site attacks' by not allowing includes of files with absolute URLS in them. Fair enough. I was considering turning that off on my localhost just to continue with development, but then i realized it might not work when I make it live on my public host, so I don't wanna risk that.
This is my problem: menu.php contains the HTML that forms my navigation menu that appears throughout the site at the top of every page. So to avoid putting it in every file, I use include "menu.php"; on all the pages. Pretty elementary technique, so that I don't have to make changes to every page (there are possibly hundreds) when I need to change it.
Problem is, if I'm viewing an HTML file in a sub-directory i.e. rootdirectory/associates/associate1.html then the relative URLS in the links in my menu.php include file don't work i.e. <a href="index.php" > because I'm in a sub-directory.
So I thought to use absolute URL's, but then I'm going to have to change them all once I move it from my localhost to my live host. So I decided to assign a variable at the top of that menu.php include file and then put that variable in the links i.e.
<?php $rootdir = 'http://localhost:8888/rootdirectory/'; ?>
<a href="<?php echo $rootdir; ?>index.php">Home</a>
and so on for every link.
But it says that's not allowed because you can't include a file with absolute URLs because that's a security risk.
So I tried DOCUMENT_ROOT:
I tested it by <?php echo $rootdir; ?> and it works; it echoes the document root. But the document root i.e. applications/MAMP/rootdirectory/ isn't going to work because I need it to say http://localhost:8888/rootdirectory/ instead.
I tried SERVER_NAME but using SERVER_NAME in an include doesn't work either because it returns localhost/ instead of localhost:8888/ which is basically useless.
So I don't know what to do. Does this make it clear? Thanks everyone.