I’m doing a little home computing project in PHP and am creating references like this…
<a href=\"list_beer.php?order_by=name\">Beer</a>
This seems to pick up the right file. When I do includes, I seem to need a pathname.
include_once ("/var/www/common.php");
I’m sure this can’t be right. Perhaps you could tell me what is the best practice for these things so that I can create scripts that aren’t tied to a particular pathname (or operating system, come to that) and so that the file selected in the first example is known/can be controlled? Perhaps some settings in php.ini or apache?
Thank you.
Actually, you need an absolute path for both.
for the web resources it should start from the web root –
/for the files you need a point where virtual path meets a filesystem one.
$_SERVER['DOCUMENT_ROOT']is for that purpose.so
and
will work as desired