I want to set attribute for a stdClass object in a single statement. I don't have any idea about it. I know the following things
$obj = new stdClass;
$obj->attr = 'loremipsum';
It takes two statements.
$obj = (object) array('attr'=>'loremipsum');
It takes single statement but it is not direct method.
$obj = new stdClass(array('attr'=>'loremipsum'));
It is not working.