KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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.
Tags (comma-separated)
Save Edits
Cancel