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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 09:01:29 2024 UTC