Is it possible to typecast a property as an object when defining the properties? For instance, $array is valid, however, my two attempts of doing so with an object are not.
Thank you
class xxx
{
public $array=array(),
$object1=new stdClass(),
$object2=object()
}
No, PHP does not allow you to do that. the only way you can assign an object to class property is via class methods.
if you want an empty class to be assigned to class property upon object initialization then you can do this trough constructor method.