#50364 [Opn->Bgs]: global keyword doesn't work as expected

From: Date: Wed, 02 Dec 2009 20:51:04 +0000
Subject: #50364 [Opn->Bgs]: global keyword doesn't work as expected
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-145348@lists.php.net to get a copy of this message
ID: 50364 Updated by: derick@php.net Reported By: damp12000 at hotmail dot com -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: Linux PHP Version: 5.2.11 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php $b exists in doInclude's scope only, because that's where it's require'd in. Previous Comments: ------------------------------------------------------------------------ [2009-12-02 20:36:44] damp12000 at hotmail dot com 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 this bug report at http://bugs.php.net/?id=50364&edit=1

« previous php.bugs (#145348) next »