title: Returning objects in php
body: <p>I see similar questions asked but I seem to have problem with more basic stuff than were asked. How to declare a variable in php? My specific problem is I have a function that reads a DB table and returns the record (only one) as an object.</p>
  
  <pre><code>class User{
     public $uid;
     public $name;
     public $status;
  }
  
  function GetUserInfo($uid)
  {
     // Query DB
  
     $userObj = new User();
  
     // convert the result into the User object.
  
     var_dump($userObj);   
     return $userObj;
  }
  
  // In another file I call the above function.
  
  ....
  
  $newuser = GetUserInfo($uid);
  
  var_dump($newuser);
  </code></pre>
  
  <p>What is the problem here, I cannot understand. Essentially the <code>var_dump()</code> in the function <code>GetUserInfo()</code> works fine. The <code>var_dump()</code> outside after the call to <code>GetUserInfo()</code> does not work. </p>