note 98839 deleted from functions.returning-values by cmb
| From: | cmb@php.net | Date: | Sun, 11 Dec 2016 23:45:51 +0000 |
| Subject: | note 98839 deleted from functions.returning-values by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208565@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
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.