note 105720 added to language.oop5
| From: | dunst0 at osu1 dot php dot net | Date: | Fri, 09 Sep 2011 00:01:06 +0000 |
| Subject: | note 105720 added to language.oop5 | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183062@lists.php.net to get a copy of this message | ||
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!
----
Server IP: 69.147.83.197
Probable Submitter: 80.171.92.138
----
Manual Page -- http://www.php.net/manual/en/language.oop5.php
Edit -- https://master.php.net/note/edit/105720
Del: integrated -- https://master.php.net/note/delete/105720/integrated
Del: useless -- https://master.php.net/note/delete/105720/useless
Del: bad code -- https://master.php.net/note/delete/105720/bad+code
Del: spam -- https://master.php.net/note/delete/105720/spam
Del: non-english -- https://master.php.net/note/delete/105720/non-english
Del: in docs -- https://master.php.net/note/delete/105720/in+docs
Del: other reasons-- https://master.php.net/note/delete/105720
Reject -- https://master.php.net/note/reject/105720
Search -- https://master.php.net/manage/user-notes.php