note 35242 deleted from function.include by sniper

From: Date: Tue, 04 Nov 2003 00:42:43 +0000
Subject: note 35242 deleted from function.include by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59795@lists.php.net to get a copy of this message
Note Submitter: peter(underscore)looij@hotmail.com ---- In addition to (dnac at NOSPAM dot linuxmail dot org) on 26-Jan-2003: When including a file from within a function or a class method, normally global variables from the include-file stay in the scope of that function. When using the $GLOBALS array in the include file the variables are accessible from your php code. It is quite obvious, but it's worth a note. ---------test.php <? class Test { function inc() { require("test3.inc"); } } $objTest = new Test(); $objTest->inc(); echo $strTest; ?> ------------------ ----------test3.inc <? $GLOBALS['strTest'] = "hi"; ?> ------------------

« previous php.notes (#59795) next »