note 92215 added to language.references

From: Date: Tue, 14 Jul 2009 18:56:47 +0000
Subject: note 92215 added to language.references
Groups: php.notes 
Request: Send a blank email to php-notes+get-158294@lists.php.net to get a copy of this message
In the following case you don't have to use = & operator when returning a reference: <?php class a { public $a = 1; } class b { static $var; public static function & gvar($i) { if(!(isset(b::$var[$i]))) { b::$var[$i] = new a; } return b::$var[$i]; } } $b = new b; $a = b::gvar(1); $a->a = 14; $c = b::gvar(1); echo $c->a; // 14 ?> Note the $a = b::gvar(1) instead of $a = & b::gvar(1)!!! ---- Server IP: 208.69.120.35 Probable Submitter: 80.101.112.134 ---- Manual Page -- http://www.php.net/manual/en/language.references.php Edit -- https://master.php.net/note/edit/92215 Del: integrated -- https://master.php.net/note/delete/92215/integrated Del: useless -- https://master.php.net/note/delete/92215/useless Del: bad code -- https://master.php.net/note/delete/92215/bad+code Del: spam -- https://master.php.net/note/delete/92215/spam Del: non-english -- https://master.php.net/note/delete/92215/non-english Del: in docs -- https://master.php.net/note/delete/92215/in+docs Del: other reasons-- https://master.php.net/note/delete/92215 Reject -- https://master.php.net/note/reject/92215 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158294) next »