note 105720 deleted from language.oop5 by danbrown
| From: | danbrown@php.net | Date: | Sat, 10 Sep 2011 14:52:16 +0000 |
| Subject: | note 105720 deleted from language.oop5 by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183077@lists.php.net to get a copy of this message | ||
Note Submitter: dunst0
----
Someone wrote that you can't create easily anonymous objects like in JavaScript,
but that's not fully true.
You can do the following:
[PHP Code]
$a = (object) array("a" => "foo", "b" => "bar");
var_dump($a);
[/PHP Code]
Which will output the following:
[OUTPUT]
object(stdClass)#1 (2) {
["a"]=>
string(3) "foo"
["b"]=>
string(3) "bar"
}
[/OUTPUT]
That is an anonymous object!