- To: slug@xxxxxxxxxxx
- Subject: Re: [SLUG] Symlinks and PHP4
- From: Del <del@xxxxxxxxxxxx>
- Date: Thu, 02 Sep 2004 21:35:26 +1000
- User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.2) Gecko/20040803
(I'll have a go at answering the actual question, rather than
posting about php.ini files which is a related, but separate,
topic).
/var/www/host.domain.tld/phpapp => /usr/share/phpapp
Then in the application directory have a config file which includes a
host-specific config file:
require_once('../config/phpapp.php');
To my mind, this should fetch
'/var/www/host.domain.tld/config/phpapp.php', but it doesn't; it looks
for '/usr/share/config/phpapp.php'.
My question is, why?
Because PHP opens files relative to the currently running script's
location. If you are running /usr/share/phpapp/myfile.php then
require_once('a.php') will require /usr/share/phpapp/a.php, regardless
of symlinks.
And the supplementary question is, how do I get
the behaviour I'm after?
require_once($_SERVER["DOCUMENT_ROOT"] . "/config/phpapp.php");
(assuming your site's document root is set to /var/www/host.domain.tld/
for each site).
You may have more luck getting answers to PHP questions at syd::php
http://sydney.ug.php.net/
--
Del