note 88460 added to language.types.object
| From: | HayleyWatson at osu1 dot php dot net | Date: | Sun, 25 Jan 2009 12:34:14 +0000 |
| Subject: | note 88460 added to language.types.object | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149751@lists.php.net to get a copy of this message | ||
Another reply to bob:
Explicit types of objects are good, as wbcarts, and Rick's solution is the one I use for a
throwaway generic object (and I do have uses for them), but there is another way to create a new
naked object and it _is_ documented on this very page.
"If a value of any other type is converted to an object, a new instance of the stdClass
built-in class is created. If the value was NULL, the new instance will be empty."
In code:
$obj = (object)null;
$obj->blah = 3;
That might still be regarded as "ghetto" - especially since Rick's suggestion is more
explicit - but it is better than a random unset.
----
Server IP: 202.89.58.1
Probable Submitter: 114.134.161.9
----
Manual Page -- http://www.php.net/manual/en/language.types.object.php
Edit -- https://master.php.net/note/edit/88460
Del: integrated -- https://master.php.net/note/delete/88460/integrated
Del: useless -- https://master.php.net/note/delete/88460/useless
Del: bad code -- https://master.php.net/note/delete/88460/bad+code
Del: spam -- https://master.php.net/note/delete/88460/spam
Del: non-english -- https://master.php.net/note/delete/88460/non-english
Del: in docs -- https://master.php.net/note/delete/88460/in+docs
Del: other reasons-- https://master.php.net/note/delete/88460
Reject -- https://master.php.net/note/reject/88460
Search -- https://master.php.net/manage/user-notes.php