Working with PHP Absolute Path differences between production server and MAMP development server

I'm running MAMP for development work in PHP, and am looking for an efficient way to write my includes so that they work properly on both the development and production server when they differ in file structure.  

To illustrate:

My absolute path on my production server is /web/something/someplace/web/site/content/include.php

My absolute path on the development server is

How do most people do this in an efficient way without having to rewrite the paths when going from development to production for everything above the site folder?
Who is Participating?
mankowitzConnect With a Mentor Commented:
I usually use seomthing like this:

if (!@include '/path/to/production/server') 

Open in new window

Another option is to make your files relative to document root, if possible:

DaveNegronAuthor Commented:
@mankowitz Along these same lines, what do you use when the file is above the document root?
To be honest, I usually do not keep documents outside the document root. I understand that this is necessary sometimes, but I find it easier to keep individual copies. In those cases, however where I can't keep the document inside the document root, then I use the first option above.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.