[PHP-DEV] PHP 4.0 Bug #2193: Global declared variables not gobal From: lemming <email protected>
Date: 08/30/99

From: lemming <email protected>
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

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>