I am having problems with locating files with php include on my Ubuntu server.
structure of site
/var/www/
home/index.php
include/header.php
When I try to insert the following include_once('/include/header.php') in the file home/index.php it does not work.
however if I change that to include_once('../include/header.php'), it works fine, but to have consistency through out my site I can’t allow this
What is the best way to fix this?
If your document root is
/var/www/then you can use:Typically, PHP gets the
DOCUMENT_ROOTcorrect so you can usually rely on that.If you want to include the file relative to the script that is doing the include, you can do: