ID: 44705 User updated by: djneoform at gmail dot com Reported By: djneoform at gmail dot com Status: Bogus Bug Type: Scripting Engine problem Operating System: Windows 2003 Standard PHP Version: 5.2.5 New Comment:
I guess this is more of an issue of php lacking pointers? (since i'm trying to do with references what can only be done with pointers i guess..) Previous Comments: ------------------------------------------------------------------------ [2008-04-12 07:15:36] [EMAIL PROTECTED] Sorry, but 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 as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. $global = 10; $var = "plop"; $arg =& $var; $arg =& $global; echo $var; // "plop" That's because $arg =& $global; (which is in your code $ref_var = &$GLOBALS['glob_var'];) will only affect the $arg variable, and set it to be a reference of $global, and leave $var untouched. ------------------------------------------------------------------------ [2008-04-11 21:55:20] djneoform at gmail dot com 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']; } ------------------------------------------------------------------------ [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