title: How to set attributes for stdClass object at the time object creation
body: <p>I want to set attribute for a <em>stdClass</em> object in a single statement.
  I don't have any idea about it. I know the following things</p>
  
  <pre><code>$obj = new stdClass;
  $obj-&gt;attr = 'loremipsum';
  </code></pre>
  
  <p>It takes two statements.</p>
  
  <pre><code>$obj = (object) array('attr'=&gt;'loremipsum');
  </code></pre>
  
  <p>It takes single statement but it is not direct method.</p>
  
  <pre><code>$obj = new stdClass(array('attr'=&gt;'loremipsum'));
  </code></pre>
  
  <p>It is not working.</p>