note 62391 added to language.references.return

From: Date: Mon, 27 Feb 2006 17:22:16 +0000
Subject: note 62391 added to language.references.return
Groups: php.notes 
Request: Send a blank email to php-notes+get-104501@lists.php.net to get a copy of this message
The note about using parentheses when returning references is only true if the variable you try to return does not already contain a reference. <?php // Will return a reference function& getref1() { $ref =& $GLOBALS['somevar']; return ($ref); } // Will return a value (and emit a notice) function& getref2() { $ref = 42; return ($ref); } // Will return a reference function& getref3() { static $ref = 42; return ($ref); } ?> ---- Server IP: 217.160.72.57 Probable Submitter: 85.183.132.90 (proxied: 1.1 router.local.rw-it.net:8080 (Squid/2.4.STABLE7)) ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/language.references.return.php Edit -- http://master.php.net/note/edit/62391 Del: integrated -- http://master.php.net/note/delete/62391/integrated Del: useless -- http://master.php.net/note/delete/62391/useless Del: bad code -- http://master.php.net/note/delete/62391/bad+code Del: spam -- http://master.php.net/note/delete/62391/spam Del: non-english -- http://master.php.net/note/delete/62391/non-english Del: in docs -- http://master.php.net/note/delete/62391/in+docs Del: other reasons-- http://master.php.net/note/delete/62391 Reject -- http://master.php.net/note/reject/62391 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104501) next »