How to get absolute path of file on server?

Can someone tell me how to get the absolute path of a file being called on the server? I need to access files that are outside of the root web directory. The path can also change due to different users having different paths due to their username (on OS X).

If I hard code this path in it works, but if someone else checks out the repo it won’t work on their machine:

<?php include("/Users/rezzner/Sites/client/dir/src/html/include/header.php"); ?>

I’d like it to be something like this instead, I just cannot find what function to use to do this:

<?php include($SOMETHING . "../include/header.php"); ?>

dirname( __FILE__ ) . '/path/to/file/from/this/file.php';

Thanks!

phpinfo(); will give you system information. If you look in the environment section, you can find the server path.

var_dump( $_SERVER ); will also give you a handle on what var does what.