Expected behaviour or bug?
| From: | Camilo Sperberg | Date: | Mon, 17 Sep 2012 08:50:05 +0000 |
| Subject: | Expected behaviour or bug? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-319107@lists.php.net to get a copy of this message | ||
Hello list, I have a little question with PHP's internal working. I've managed to reduce
the test to the following lines:
$globalVariable = 'i am a global variable';
function testFunction() {
global $globalVariable;
unset($globalVariable);
}
testFunction();
if(isset($globalVariable)) {
var_dump('global variable IS set');
} else {
var_dump('global variable is NOT set');
}
When executing the above test, you will get printed that the global variable is set, despite
unsetting it in the function. Is it really the intention to unset a global variable inside a
function locally or have I just happen to found a little bug?
unreal4u-MBP:~ unreal4u$ php --version
PHP 5.3.13 with Suhosin-Patch (cli) (built: Jun 20 2012 17:05:20)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.3.0dev, Copyright (c) 2002-2012, by Derick Rethans
If it is expected behavior, is there any documentation on why this is done this way?
Greetings and thanks.