note 84292 deleted from language.oop5 by peehaa
| From: | peehaa@php.net | Date: | Sun, 28 Apr 2019 10:03:39 +0000 |
| Subject: | note 84292 deleted from language.oop5 by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210735@lists.php.net to get a copy of this message | ||
Note Submitter: Jason
----
For real quick and dirty one-liner anonymous objects, just cast an associative array:
<?php
$obj = (object) array('foo' => 'bar', 'property' =>
'value');
echo $obj->foo; // prints 'bar'
echo $obj->property; // prints 'value'
?>
... no need to create a new class or function to accomplish it.