Re: Includes

From: Date: Sun, 20 Apr 2003 17:58:47 +0000
Subject: Re: Includes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144559@lists.php.net to get a copy of this message
Hi Darren, define('WINDOWS',substr(PHP_OS, 0, 3) == 'WIN'); $ipath = ini_get('include_path'); if (WINDOWS) $sep = ';'; else $sep = ':'; ini_set('include_path',$ipath . $sep . '/var/www/html'); require_once('header.php'); regards, Greg -- phpDocumentor http://www.phpdoc.org Darren Young wrote:
Is there any way to "dynamically" alter the include path during a page load? Something like Perl's use lib idea. I'm in a shared hosting environment where I don't have access to the php.ini file. The web root on the chroot host is /var/www/html and is where all of my include files are at. If I:
     require_once("header.php");
From a page within /var/www/html it works fine. If I (per my ISP's instructions):
     require_once("/header.php");
It fails (can't find include). If I:
     require_once("header.php");
     require_once("/header.php");
From any page in any directory below /var/www/html it fails (the usual error). Question with the / in the require. Is that going to the server root (/) directory to look for the page or the root of the site the calling page is loading from? Can I somehow "push" /var/www/html onto the include stack during the initial page load somehow (perl's push(@INC) kind of thing? Should I / could I somehow grab the server name from the QUERY_STRING and prepend that to the require then fetch the page over HTTP?


« previous php.general (#144559) next »