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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 14 = ?
Subscribe to this entry?

 
 [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: Sat May 11 01:01:31 2024 UTC