note 50038 deleted from function.list by googleguy

From: Date: Thu, 13 Sep 2012 10:07:45 +0000
Subject: note 50038 deleted from function.list by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190709@lists.php.net to get a copy of this message
Note Submitter: mortoray at ecircle-ag dot com ---- 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 );

« previous php.notes (#190709) next »