php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9863 "global $var" incompatibility between PHP 3 & 4
Submitted: 2001-03-20 06:27 UTC Modified: 2001-03-20 06:40 UTC
From: hartmut at six dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.4pl1 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hartmut at six dot de
New email:
PHP Version: OS:

 

 [2001-03-20 06:27 UTC] hartmut at six dot de
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-20 06:40 UTC] hholzgra@php.net
can't reproduce anymore, please ignore
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 18:02:40 2024 UTC