Include ("Absolute Path") of a file?

Posted on 16th Feb 2014 by admin

I'm not sure what I'm doing wrong. I am writing my php code in the same directory of the file that I wish to include is in. So, here's what I have written:

Code: include ('file.php');
This works without any problems. However, I wish to link to this file using an absolute path, rather than a relative one. According to most online tutorials, I would use the following code:

Code: include ($_SERVER['DOCUMENT_ROOT'] . '/directory/file.php');
However, this does not work. Does anyone know what the problem might be?

Other forums