note 94174 deleted from language.references.pass by danbrown

From: Date: Wed, 21 Oct 2009 00:28:17 +0000
Subject: note 94174 deleted from language.references.pass by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161928@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- As stated in the documentation, passing values by reference is not supported by PHP. <?php function bar() // Note the missing & { $a = 5; return $a; } foo(bar()); // Produces fatal error since PHP 5.0.5 ?> The return value of bar() cannot be passed by reference to foo(&$something). However the following seems to be valid: <?php $test = bar(); foo($test); ?> You may also encounter problems for calls with fixed values, such as: <?php foo(null); // Produces fatal error foo(5); // Produces fatal error ?> The following calls (by putting the values in variables) are possible: <?php $null = null; foo($null); $five = 5; foo($five); ?> Is there any reason that passing a fixed value is not supported by PHP? I guess this limitation just causes avoidable problems.

« previous php.notes (#161928) next »