From:             kingoleg at mail dot ru
Operating system: All
PHP version:      Irrelevant
PHP Bug Type:     Documentation problem
Bug description:  Error or missing overview of unset() function

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 bug report at http://bugs.php.net/?id=29428&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29428&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29428&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29428&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29428&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29428&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29428&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29428&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29428&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29428&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29428&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29428&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29428&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29428&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29428&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29428&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29428&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29428&r=float

Reply via email to