php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #15696 Can't set/unset global-ed variables
Submitted: 2002-02-24 10:10 UTC Modified: 2002-02-24 12:04 UTC
From: marekm at aptus dot pl Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.1.1 OS: Linux & Win32
Private report: No CVE-ID: None
 [2002-02-24 10:10 UTC] marekm at aptus dot pl
I'm running the following script:

$id=1;
function test()
{
	global $id;
	unset($id);
}
test();
echo($id);

As the function test is being executed I think, the $id variable should be unset and so the script should output nothing, but it outputs 1. It IS possible to change the value od $id inside the 'test' function, it's just not possible to change the set/unset state. 
It's easy to omit the problem by unsetting $GLOBALS["id"] variable, but I think it should be possible to unset the global-ed variable in both ways.
The problem affects all PHP 4.x versions. The 3.x versions work as I expect.

Regards,
Marek Matula


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-24 10:12 UTC] derick@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php
 [2002-02-24 10:27 UTC] yohgaki@php.net
Read manual about reference. You are unsetting reference to global. Not the actual var.
 [2002-02-24 10:52 UTC] marekm at aptus dot pl
OK, I know that.
I was just moving an old PHP3 script to PHP4 and noticed that problem.
Anyway, there's nothing mentioned in "Migrating from PHP 3.0 to PHP 4.0" section of the manual about this (significant I think) change. 

Thanks for the reply,

Marek Matula
 [2002-02-24 11:46 UTC] mfischer@php.net
Re-Opening as documentation problem.
 [2002-02-24 12:04 UTC] nohn@php.net
This bug has been fixed in CVS.

Fixed this bug in cvs. I hope the description is well enough...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 22:01:26 2024 UTC