ID: 44705
User updated by: djneoform at gmail dot com
Reported By: djneoform at gmail dot com
-Status: Bogus
+Status: Open
Bug Type: Scripting Engine problem
Operating System: Windows 2003 Standard
PHP Version: 5.2.5
New Comment:
I made a mistake in the sample code, should read like this:
$GLOBALS['glob_var'] = 10;
funk($var);
echo 'SHOULD BE 10: '.$var;
function funk(&$ref_var)
{
$ref_var = &$GLOBALS['glob_var'];
}
Previous Comments:
------------------------------------------------------------------------
[2008-04-11 21:47:27] [EMAIL PROTECTED]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
You don\'t even return anything from the funk() function... so of
course $ref == NULL.
------------------------------------------------------------------------
[2008-04-11 21:02:45] djneoform at gmail dot com
Description:
------------
If you pass a variable by reference in a function, then within the
function assign that variable a reference to another variable, the
variable's reference gets overwritten and the variable (when the
function ends) contains null.
Reproduce code:
---------------
$GLOBALS['glob_var'] = 10;
$var = funk($ref_var);
echo 'SHOULD BE 10: '.$var;
function funk(&$ref_var)
{
$ref_var = &$GLOBALS['glob_var'];
}
Expected result:
----------------
> SHOULD BE 10: 10
Actual result:
--------------
> SHOULD BE 10:
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44705&edit=1