php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #17435 unset() of the globalized variable
Submitted: 2002-05-26 13:21 UTC Modified: 2002-05-28 09:00 UTC
From: ivun at mail dot ru Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 4.2.0 OS: Linux/Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ivun at mail dot ru
New email:
PHP Version: OS:

 

 [2002-05-26 13:21 UTC] ivun at mail dot ru
The article about unset() says: "If a globalized variable is unset() inside of a function, only the local variable is destroyed.  The variable in the calling environment will retain the same value as before unset() was called." It is != true!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-26 13:23 UTC] derick@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.

unset()\'s documentation is perfectly right on this point.
 [2002-05-26 13:34 UTC] ivun at mail dot ru
Are you completely sure? But why are the globalized variables destroyed in my scripts?

Ps. Another bug is handling ' and \ in Bug Report system :)
 [2002-05-26 15:04 UTC] goba@php.net
Can you please provide us with a code where we
can reproduce what you've said?
 [2002-05-27 12:02 UTC] ivun at mail dot ru
Sure.

My script works with sockets and there is a function that closes the socket and destroys all the variables connected to it. $output and $input are arrays of sockets. Here is the code:

function socket_kill_my_socket($i) {
global $fset, $output, $input;
	$fnd = array_search($i, $fset);
	unset($fset[$fnd]);
	unset($output[$i]);
	unset($input[$i]);
	socket_shutdown($i); //???
	socket_close($i);
	echo "Closed $i<BR>";
}
 [2002-05-28 09:00 UTC] goba@php.net
Please read the manual carefully. You have never used
unset($input), which would be the case described by
that sentence you have quoted. You've never unset the 
globalized variable, so that sentence is in no
relation to your code. There's no need to correct the 
documentation, it's already correct.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 11:01:33 2024 UTC