Re: nested includes()...

From: Date: Wed, 10 Oct 2001 13:36:41 +0000
Subject: Re: nested includes()...
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-70656@lists.php.net to get a copy of this message
yeah.. from all the solutions presented here... this is the best one so far... altough I have to keep including one file in every script I have (which I think is not so "nice"), works fine.... I think PHP could think about something like global.asa, I guess that would be not so tough to implement and would be a great adition... it doesn't depend on the php.ini and solves this problem with perfection... what do you guys think??? At 19:01 09/10/01 -0400, Jason G. wrote:
This is how I have taken care of my include problems. --------------------------------------------------------------- I create a file in each directory called _stdinc.php which contains: <?
        define('_INCLUDE_DIR', '../../include/');
        include(_INCLUDE_DIR . 'stdinc.php');
?> In the include dir, I have a script called stdinc.php which contains: <?
        include(_INCLUDE_DIR . 'lib.data.php');
        include(_INCLUDE_DIR . 'lib.sessions.php');
        include(_INCLUDE_DIR . 'lib.forms.php');
        include(_INCLUDE_DIR . 'lib.email.php');
?> At the top of every script, I simply write: <?
        require('_sdtinc.php');
        .
        .
        .
This way, if I change move directory's, I only have to edit _stdinc.php in each dir that changes. ------------------------------------------------------------------------------------- I have a more efficient way worked out that lets you optionally include whichever headers you want in a particular script by saying: <?
        define('_INCLUDE_LIST','CORE, LIB_DATA, LIB_EMAIL');  //Optional
        require('_stdinc.php');
        .
        .
        .
Let me know if you, or anyone wants to make use of that method. -Jason Garber IonZoft.com At 02:33 PM 10/9/2001 -0300, Christian Dechery wrote: that way if the include dir changes I have to go trough each file to change it?? that doesn't solve my problem at all... At 23:00 08/10/01 -0400, Jason G. wrote: Alas, I have your solution! I have gotten around this very problem by saying at the top of a script: define(_INCLUDE_DIR, '/home/pad/include/'); //note trailing slash Anytime i include a file: include(_INCLUDE_DIR . "lib.data.php"); It works always. -Jason Garber IonZoft.com At 10:20 PM 10/8/2001 -0300, Christian Dechery wrote: I have a file x.php that includes a.inc, and a.inc includes b.inc... if I have a file dir/z.php including ../a.inc it doesn't work cuz it won't find b.inc... how can I get around this??? _____________________________ . Christian Dechery . . Gaita-L Owner / Web Developer . . http://www.webstyle.com.br . . http://www.tanamesa.com.br -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#70656) next »