note 50038 added to function.list

From: Date: Wed, 16 Feb 2005 09:29:45 +0000
Subject: note 50038 added to function.list
Groups: php.notes 
Request: Send a blank email to php-notes+get-85102@lists.php.net to get a copy of this message
There is no way to do reference assignment using the list function, therefore list assignment is will always be a copy assignment (which is of course not always what you want). By example, and showing the workaround (which is to just not use list): function &pass_refs( &$a ) { return array( &$a ); } $a = 1; list( $b ) = pass_refs( $a ); //* $a = 2; print( "$b" ); //prints 1 $ret = pass_refs( $a ); $b =& $ret[0]; $a = 3; print( "$b" ); //prints 3 *This is where some syntax like the following would be desired: list( &$b ) = pass_refs( $a ); or maybe: list( $b ) =& pass_refs( $a ); ---- Manual Page -- http://www.php.net/manual/en/function.list.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50038 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50038&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50038&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50038&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50038&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50038&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50038&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85102) next »