#50364 [NEW]: global keyword doesn't work as expected
| From: | damp12000 at hotmail dot com | Date: | Wed, 02 Dec 2009 20:36:44 +0000 |
| Subject: | #50364 [NEW]: global keyword doesn't work as expected | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-145347@lists.php.net to get a copy of this message | ||
From: damp12000 at hotmail dot com
Operating system: Linux
PHP version: 5.2.11
PHP Bug Type: *General Issues
Bug description: global keyword doesn't work as expected
Description:
------------
'global' keyword in a function does not work as expected when an file is
included from within a function scope
Reproduce code:
---------------
file b1.php
<?
$a = '1';
doInclude();
function doInclude() {
require('b2.php'); }
?>
file b2.php
<?
$b = '2';
testGlobalScope();
function testGlobalScope() {
global $a,$b;
print("$a\n$b\n");
}
?>
Expected result:
----------------
1
2
Actual result:
--------------
1
--
Edit bug report at http://bugs.php.net/?id=50364&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50364&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50364&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50364&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50364&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50364&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50364&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50364&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50364&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50364&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50364&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50364&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50364&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50364&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50364&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50364&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50364&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50364&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50364&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50364&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50364&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50364&r=mysqlcfg