nested includes

From: Date: Mon, 17 Jan 2000 22:44:56 +0000
Subject: nested includes
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-9203@lists.php.net to get a copy of this message
I really needed the ability to have include files include other files. After some struggling, I have something that works w/beta2 of PHP4. Please let me know if I'm going to break w/a current or future version. If it holds up, I hope it helps others to solve this common affliction. (for a file called constants.ph) <? if ("string" == gettype( CONSTANTS_PH )) { define( "CONSTANTS_PH", 1 ); // constants shared by all pages } // end of if (! CONSTANTS_PH ) ?> Some of you will instantly get it, but it took me a while to realize that testing for CONSTANTS_PH was tough because it would be treated as a string, due to the relaxed quote requirements of PHP. In this scenario if it's not explicitly set to be an integer, it is "undefined" and will return "string" from gettype. Dan Sevush CTO DansChocolates.com (happily using PHP since launch)

« previous php.version4 (#9203) next »