Posted by Sandman on 09/05/05 23:59
In article <a1a977a213f4a88c780622e40e800@news.pandora.be>,
tom pester <Tom.PesterDELETETHISSS@pandora.be> wrote:
> Hi,
>
> Im new to php and have a background in asp. All the help is very much
> appreciated.
>
> today I was using the include function in a file that itself gets included :
>
> ***************
> consumer.php : <? include "inc.php" ?>
>
> inc.php : <? include "Common/functions.php" ?>
>
> functions.php : common functions that all pages use
> ***************
>
> This works fine if the path that's specified in
> <? include "Common/functions.php" ?>
> is relative to the path of the calling page consumer.php
>
> I want to be able to specify <? include "inc.php" ?> in every page no matter
> if its nested in a directory or not.
>
> In asp I would use absolute paths like this : /Common/functions.php and it
> would work.
> PHP comes close to it when using paths like this :
> c:/website/site1/Common/functions.php
>
> But thus breaks when I transfer the pages from the development server to
> the live server cause there is no c:/website/site1
>
> My next guess was that I could solve this with a variable like this :
> $docroot
> . "/Common/functions.php" but where do I specify $docroot in a central
> location?
> (I would do this in asp's global.asa)
>
> _SERVER["DOCUMENT_ROOT"] is blank when I request it and, if I understand
> it correclty, I can set it in the php.ini . The problem is this value holds
> for all the sites on the box.
>
> I'm new to php so if I don't make sense than pls put me straight :)
You can specify the include_path in php.ini to a path shared by all
environments.
include_path on your dev machine could be c:/websites/includes/ and on your
server c:/includes/ and keep them in sync.
--
Sandman[.net]
[Back to original message]
|