stdClass is the default PHP object. stdClass has no properties, methods or parent. It does not support magic methods, and implements no interfaces.
When you cast a scalar or array as Object, you get an instance of stdClass. You can use stdClass whenever you need a generic object instance.
<?php
$x = new stdClass;
$y = (object) null; $z = (object) 'a'; $a = (object) array('property1' => 1, 'property2' => 'b');
?>
stdClass is NOT a base class! PHP classes do not automatically inherit from any class. All classes are standalone, unless they explicitly extend another class. PHP differs from many object-oriented languages in this respect.
<?php
class CTest {
public $property1;
}
$t = new CTest;
var_dump($t instanceof stdClass); var_dump(is_subclass_of($t, 'stdClass')); echo get_class($t) . "\n"; echo get_parent_class($t) . "\n"; ?>
You cannot define a class named 'stdClass' in your code. That name is already used by the system. You can define a class named 'Object'.
You could define a class that extends stdClass, but you would get no benefit, as stdClass does nothing.
(tested on PHP 5.2.8)