|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5884 Not able to unset($var) set as global in function
Submitted: 2000-07-31 23:29 UTC Modified: 2000-08-01 00:11 UTC
From: php42 at hotmail dot com Assigned:
Status: Closed Package: Other
PHP Version: 4.0.1pl2 OS: Linux
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:
Solve the problem:
28 + 7 = ?
Subscribe to this entry?

 [2000-07-31 23:29 UTC] php42 at hotmail dot com

function foo() {
  global $test;
  $test = $test . " - foo";

if (isset($test)) { echo "Set: $test"; } else { echo "Unset"; }
echo "<br>";
if (isset($test)) { echo "Set: $test"; } else { echo "Unset"; }


echos out:

Set: test - foo


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-01 00:11 UTC]
taken from the site:
"unset() now breaks the association between a locally scoped variable and one that is globally scoped if the reference is made using the "global" keyword."

I?ll not recommend you to touch the $GLOBALS array directly ;)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 07:01:28 2024 UTC