note 69901 deleted from language.references.pass by googleguy

From: Date: Sun, 23 Feb 2014 17:25:45 +0000
Subject: note 69901 deleted from language.references.pass by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198615@lists.php.net to get a copy of this message
Note Submitter: petruzanautico at yahoo dot com dot ar ---- Actually there is a way to give a default value to a reference argument, if you need it badly. It fires a warning, but you can prefix the function call with an @. Of course, you cannot pass literals by reference. <?php function byref( &$ref ) { if( !isset( $ref ) ) $ref = "default value"; print $ref; // default or given value? who knows! } $hi = "some value "; byref( $hi ); // works fine @byref(); // missing argument warning, but works byref( "hey!" ); // this will raise a fatal error ?>

« previous php.notes (#198615) next »