Object initialization
To create a new object object, instantiate a class using the new statement:
<?php class foo { function do_foo() { echo "Doing foo."; } } $bar = new foo; $bar->do_foo(); ?>
Convert to object
If you convert an object to an object, it will not change anything. If a value of any other type is converted to an object, an instance of the built-in class stdClass will be created. If the value is NULL, the new instance is empty. Converting an array to an object will cause the keys to become property names with corresponding values. For any other value, the member variable named scalar will contain the value.
<?php $obj = (object) 'ciao'; echo $obj->scalar; // outputs 'ciao' ?>