note 84292 added to language.oop5
| From: | Jason at osu1 dot php dot net | Date: | Tue, 08 Jul 2008 05:34:38 +0000 |
| Subject: | note 84292 added to language.oop5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141258@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 64.71.164.2
Probable Submitter: 24.196.230.22
----
Manual Page -- http://www.php.net/manual/en/language.oop5.php
Edit -- https://master.php.net/note/edit/84292
Del: integrated -- https://master.php.net/note/delete/84292/integrated
Del: useless -- https://master.php.net/note/delete/84292/useless
Del: bad code -- https://master.php.net/note/delete/84292/bad+code
Del: spam -- https://master.php.net/note/delete/84292/spam
Del: non-english -- https://master.php.net/note/delete/84292/non-english
Del: in docs -- https://master.php.net/note/delete/84292/in+docs
Del: other reasons-- https://master.php.net/note/delete/84292
Reject -- https://master.php.net/note/reject/84292
Search -- https://master.php.net/manage/user-notes.php