php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8790 set global in function
Submitted: 2001-01-18 13:03 UTC Modified: 2001-03-10 00:30 UTC
From: koyama at hoge dot org Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: FreeBSD-4.1
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: koyama at hoge dot org
New email:
PHP Version: OS:

 

 [2001-01-18 13:03 UTC] koyama at hoge dot org
If set global variables as global in function,
first time works fine, but second wrong.
=======================
<?php
$hoge = 'hoge';
function a() {
  while (list($name,) = each( $GLOBALS )) {
    global $$name;
  }
  echo "hoge: $hoge<br>\n";
}
a();
a();
a();
?>
=======================
It displays
=======================
hoge: hoge
hoge:
hoge:
=======================


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-10 00:30 UTC] koyama at hoge dot org
Sorry, it's my mistake.
reset() is required.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 15:01:30 2025 UTC