note 45877 deleted from function.include by tomsommer

From: Date: Wed, 22 Sep 2004 19:29:52 +0000
Subject: note 45877 deleted from function.include by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77181@lists.php.net to get a copy of this message
Note Submitter: php at boonhead dot nl ---- I had a problem with globals not working proper in combination with include(). <? // First script. ]----------------------------------- // The second script will work fine if you would include here. // // include("second_script.php"); function IncludeRecursive() { // Here the second script will not work as expected because include is used in a function and thus all "global" variables of the second script are treated as local to the IncludeRecusive() function of the first script. // ... include("second_script.php"); // ... } ?> <? // Second script. ]----------------------------------- // That's why you have to use $GLOBALS["strGlobalVariable"] here. // $strGlobalVariable = "The true meaning lies in your head, and does not come out when said. - BoonHead"; function SayIt() { global $strGlobalVariable; echo($strGlobalVariable); } ?> dUh|BoonHead.nl

« previous php.notes (#77181) next »