#29428 [Opn->Bgs]: Error or missing overview of unset() function
| From: | vrana@php.net | Date: | Wed, 28 Jul 2004 13:57:00 +0000 |
| Subject: | #29428 [Opn->Bgs]: Error or missing overview of unset() function | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969362323@lists.php.net to get a copy of this message | ||
ID: 29428
Updated by: vrana@php.net
Reported By: kingoleg at mail dot ru
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: All
PHP Version: Irrelevant
New Comment:
It's described pretty well, there's even example on this. Assigning
null is slightly different from unsetting (e.g. variable stays in
parent array with null value).
Previous Comments:
------------------------------------------------------------------------
[2004-07-28 14:07:32] kingoleg at mail dot ru
Description:
------------
In http://ua2.php.net/unset nothing said about how work
unset() on
local variables (PASSED BY REFERENCE or NOT).
unset() always "destroy" variables in local area. See code 1.
May be would be good to write, that for variable PASSED BY REFERENCE we
can use operation = null to unset variable. See code 2.
Reproduce code:
---------------
<?php
function a() {
$foo = 'ok';
b($foo);
var_dump($foo);
}
function b(&$foo) {
$foo = 'not ok';
unset($foo);
}
a();
?>
<?php
function a() {
$foo = 'ok';
b($foo);
var_dump($foo);
}
function b(&$foo) {
$foo = 'not ok';
$foo=null;
}
a();
var_dump($b);
?>
Expected result:
----------------
For code 1.
One of tree:
1. 'ok'
2. 'not ok'
3. variable $foo is null (not setted)
For code 2.
NULL NULL
Actual result:
--------------
'not ok'
NULL NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29428&edit=1