What is stdClass in PHP?

Keira Nighly picture Keira Nighly · May 31, 2009 · Viewed 583.2k times · Source

Please define what stdClass is.

Answer

Ciaran McNulty picture Ciaran McNulty · Jun 14, 2009

stdClass is just a generic 'empty' class that's used when casting other types to objects. Despite what the other two answers say, stdClass is not the base class for objects in PHP. This can be demonstrated fairly easily:

class Foo{}
$foo = new Foo();
echo ($foo instanceof stdClass)?'Y':'N';
// outputs 'N'

I don't believe there's a concept of a base object in PHP