PHP 4.0 Bug #2193: Global declared variables not gobal

From: Date: Mon, 30 Aug 1999 14:25:02 +0000
Subject: PHP 4.0 Bug #2193: Global declared variables not gobal
Groups: php.dev 
Request: Send a blank email to php-dev+get-10351@lists.php.net to get a copy of this message
From: lemming@k332.feld.cvut.cz Operating system: Linux 2.0.36 PHP version: 4.0 Beta 2 PHP Bug Type: Scripting Engine problem Bug description: Global declared variables not gobal It may be just "feature", but it is not documented to behave so: If I include file within a function and that file declares global variables, they are not really global: file t1.php: <? $T=1; function Test() { global $T; echo "T=$T\n"; } Test() ?> file t2.php: <? function Test2() { include('t1.php'); } Test2(); ?> 'php t1.php' gives T=1 'php t2.php' gives T= it is (unset). If I define T global in Test2(), it works - but it requires Test2 to know which global variables (configuration etc...) Test() uses... Michal Kara alias lemming

« previous php.dev (#10351) next »