note 88460 deleted from language.types.object by danbrown
| From: | danbrown@php.net | Date: | Tue, 27 Jan 2009 02:42:00 +0000 |
| Subject: | note 88460 deleted from language.types.object by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149825@lists.php.net to get a copy of this message | ||
Note Submitter: Hayley Watson
----
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.