From:             [EMAIL PROTECTED]
Operating system: any
PHP version:      5.1.0RC1
PHP Bug Type:     Scripting Engine problem
Bug description:  Inconsistent handling of $GLOBALS from included files

Description:
------------
test.php

  <?php
  include_once 'foo.php';
  var_dump($GLOBALS['foo']);
  ?>

foo.php

  <?php
  $foo = 'bar';
  ?>

Output

  string(3) "bar"


test.php

  <?php
  class PHPUnit2_Util_Fileloader {
      public static function checkAndLoad($filename) {
          include_once $filename;
      }
  }

  PHPUnit2_Util_Fileloader::checkAndLoad('foo.php');
  var_dump($GLOBALS['foo']);
  ?>

foo.php

  <?php
  $foo = 'bar';
  ?>

Output

  NULL


test.php

  <?php
  class PHPUnit2_Util_Fileloader {
      public static function checkAndLoad($filename) {
          include_once $filename;
      }
  }

  PHPUnit2_Util_Fileloader::checkAndLoad('foo.php');
  var_dump($GLOBALS['foo']);
  ?>

foo.php

  <?php
  $GLOBALS['foo'] = 'bar';
  ?>

Output

  string(3) "bar"

Reproduce code:
---------------
test.php

  <?php
  class PHPUnit2_Util_Fileloader {
      public static function checkAndLoad($filename) {
          include_once $filename;
      }
  }

  PHPUnit2_Util_Fileloader::checkAndLoad('foo.php');
  var_dump($GLOBALS['foo']);
  ?>

foo.php

  <?php
  $foo = 'bar';
  ?>

Expected result:
----------------
string(3) "bar"

Actual result:
--------------
NULL

-- 
Edit bug report at http://bugs.php.net/?id=34689&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34689&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34689&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34689&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34689&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34689&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34689&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34689&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34689&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34689&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34689&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34689&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34689&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34689&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34689&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34689&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34689&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34689&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34689&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34689&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34689&r=mysqlcfg

Reply via email to