note 69901 added to language.references.pass
| From: | petruzanautico at yahoo dot com dot ar | Date: | Mon, 25 Sep 2006 20:30:25 +0000 |
| Subject: | note 69901 added to language.references.pass | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117652@lists.php.net to get a copy of this message | ||
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
?>
----
Server IP: 201.216.232.3
Probable Submitter: 200.114.166.165
----
Manual Page -- http://www.php.net/manual/en/language.references.pass.php
Edit -- https://master.php.net/note/edit/69901
Del: integrated -- https://master.php.net/note/delete/69901/integrated
Del: useless -- https://master.php.net/note/delete/69901/useless
Del: bad code -- https://master.php.net/note/delete/69901/bad+code
Del: spam -- https://master.php.net/note/delete/69901/spam
Del: non-english -- https://master.php.net/note/delete/69901/non-english
Del: in docs -- https://master.php.net/note/delete/69901/in+docs
Del: other reasons-- https://master.php.net/note/delete/69901
Reject -- https://master.php.net/note/reject/69901
Search -- https://master.php.net/manage/user-notes.php