You are here: Re: is stdClass officially supported by PHP ? « PHP Programming Language « IT news, forums, messages
Re: is stdClass officially supported by PHP ?

Posted by Skrol29 on 12/18/11 11:49

Thanks Janwillem,

It seems that :
$obj = (object) null;
is documented, but the equivalent :
$obj = new clsClass;
is not documented, except in the examples provided under the doc.
clsClass is just mentioned to be a special class name but usage is not
described. Which maybe means it can change in the future.

------------------------------------------
Skrol29
http://www.tinybutstrong.com
------------------------------------------

Janwillem Borleffs a écrit :

> Skrol29 wrote:
> > Unfortunately the few that the documentation officially tells about
> > this class is:
> > ******************************
> > The name stdClass is used internally by Zend and is reserved. You
> > cannot have a class named stdClass in PHP.
> > http://www.php.net/manual/en/language.oop.php
> > ******************************
> >
> > It seems that some Pear packages instanciate this class.
> > But should we do the same for code intended for public releases?
> >
>
> This just means you cannot do:
>
> class stdClass {}
>
> But can savely do:
>
> $foo = new stdClass;
>
> Another example:
>
> $obj = (object) null;
> print is_a($obj, 'stdClass') ? 1 : 0;
>
> Or:
>
> $obj = (object) null;
> print $obj instanceof stdClass ? 1 : 0;
>
> Both print 1...
>
>
> JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация