The generic stdclass class in PHP (standard object)
I’m new to Object Oriented Programming in PHP and keep forgetting what the name of the generic PHP object is called.
Hence, I have created this post so I can keep a note of it.
Its called: stdclass
This acts as a built-in base class used to quickly create objects on the fly without having to write the code that formally defines it :
$cat = new stdClass;
$cat->furColour = ‘black’;
—
Problems
Jaxxed commented on its use on the mamboserver forum, see link below, and basically said that its a bit of a smelly type of variable to use and advises fellow coders make their own base class for use in scripts. Thus, one can add a bit more functionality and introspection capabilities.
Related Pages
* A forum thread discussing stdclass: http://forum.mamboserver.com/showthread.php?t=936
* See how stdclass can catch you when you least expect it.

May 12th, 2009 at 10:24 pm
thanks for this i am new to OO PHP so this was helpful
October 9th, 2009 at 11:08 am
Thank you, very helpful. Short and to the point, well done!
August 2nd, 2010 at 9:58 am
its really helpful