Edit report at http://bugs.php.net/bug.php?id=52281&edit=1
ID: 52281 Updated by: j...@php.net Reported by: keithm at aoeex dot com Summary: New Unref function - breaks reference between variables. -Status: Open +Status: Wont fix Type: Feature/Change Request -Package: Unknown/Other Function +Package: Scripting Engine problem PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Nope, see above. Previous Comments: ------------------------------------------------------------------------ [2010-07-30 07:37:25] bastard dot internets at gmail dot com keithm at aoeex dot com - Basically, you mean a shortcut for referencing: "$temp_b = $b; $b =& $temp_b; unset($temp_b);"? In other words... <?php $a = 1; $b =& $a; // reference made $temp_b = $b; $b =& $temp_b; unset($temp_b); // break reference to $a, but could be shortened to a new built-in function "unref($b);" $b = 2; echo $a."\n"; // 1 echo $b."\n"; // 2 ?> The only user defined function I could get to work even similarly is... <?php function &unref($var) { return $var; } $b =& unref($a); ?> With these shortcuts in mind, is a new built-in function still needed? ------------------------------------------------------------------------ [2010-07-07 19:02:46] keithm at aoeex dot com Description: ------------ An addition to PHP that would be nice is a way to break a reference between two variables, without destroying them. Currently, the only way I found to break a reference is to use unset($var), however this causes the variable to be destroyed which causes can cause undesirable side-effects on classes. Suggested function: unref($var) - Removes references from $var. The function would give $var whatever value it currently has via it's reference, and then removes the reference. Test script: --------------- Example of problem prompting this: See: http://www.aoeex.com/extras/unref.php Pastebin (in-case main url is down): http://pastebin.com/BtWeasC1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52281&edit=1