PHP 4.0 Bug #9863: "global $var" incompatibility between PHP 3 & 4
| From: | hartmut at six dot de | Date: | Tue, 20 Mar 2001 11:27:25 +0000 |
| Subject: | PHP 4.0 Bug #9863: "global $var" incompatibility between PHP 3 & 4 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-49478@lists.php.net to get a copy of this message | ||
From: hartmut@six.de
Operating system: *
PHP version: 4.0.4pl1
PHP Bug Type: Scripting Engine problem
Bug description: "global $var" incompatibility between PHP 3 & 4
consider the following code snippet:
<?
function foo() {
global $bar;
$bar="hello";
}
foo();
echo $bar;
?>
in PHP 3 calling foo() will create a global variable $bar
if it doesn't exist
in PHP 4 there will be no $bar after calling foo
i think PHP 4 should behave like PHP 3 here not only due
to compatibility reasons but also due to the "least supprise" rule
--
Edit Bug report at: http://bugs.php.net/?id=9863&edit=1