1

I'm not sure if I've posted the title correct as I'm not sure if there's a tehnical title for what I'm looking for - see below.

On my localhost server I have a clone of my VPS files as I wish to sync them via git.

My index.php file contains PHP includes for header and footer:

<?php include(/web/modules/footer.php); ?>

On the VPS the website is hosted inside /home/website. On my localhost (XAMPP on Mac OS X) at htdocs/website.

On localhost the index.php will not load the stylesheets or the footer.php if the / is at the begining of the PHP include.

Is there any way around so I can make XAMPP to behave correctly with /?

Thank you.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
Max
  • 151
  • 1
  • 7

1 Answers1

0

Simply put $_SERVER["DOCUMENT_ROOT"] at the start, for example, <?php include($_SERVER["DOCUMENT_ROOT"] . "/web/modules/footer.php"); ?>

The reason why the slash at the start doesn't work is because you are making PHP look in the root of the drive the script is on for footer.php.

Hope this helps.

Adam
  • 1
  • Is there any other way around? Maybe a way around without modifying the PHP code. Unfortunatelly I'm not using only PHP include, but severals plus some basic links that start with /link and are pointing to my localhost rather than my localhost/website.Thank you. – Max Mar 14 '11 at 22:55
  • Another way would be to set the include_path in `php.ini` to include the folder your include scripts are in. More information available at PHP's Website: http://www.php.net/manual/en/ini.core.php#ini.include-path – Adam Mar 18 '11 at 22:48