note 98839 added to functions.returning-values

From: Date: Sat, 10 Jul 2010 02:54:02 +0000
Subject: note 98839 added to functions.returning-values
Groups: php.notes 
Request: Send a blank email to php-notes+get-170855@lists.php.net to get a copy of this message
As of at least PHP 5.3, a function or class method returning an object acts like an object. <?php class A { function test() { echo "Yay!"; } } function get_obj() { return new A(); } get_obj()->test(); // "Yay!" ?> Sorry, still doesn't work with arrays. Ie <?php echo get_array()[1]; ?> fails. ---- Server IP: 69.147.83.197 Probable Submitter: 70.124.94.109 ---- Manual Page -- http://www.php.net/manual/en/functions.returning-values.php Edit -- https://master.php.net/note/edit/98839 Del: integrated -- https://master.php.net/note/delete/98839/integrated Del: useless -- https://master.php.net/note/delete/98839/useless Del: bad code -- https://master.php.net/note/delete/98839/bad+code Del: spam -- https://master.php.net/note/delete/98839/spam Del: non-english -- https://master.php.net/note/delete/98839/non-english Del: in docs -- https://master.php.net/note/delete/98839/in+docs Del: other reasons-- https://master.php.net/note/delete/98839 Reject -- https://master.php.net/note/reject/98839 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#170855) next »