title: accessing a global php object in a function is resulting in error
body: <p><code>$db=new DataBase();</code></p>
  
  <p>It is a object I created globaly. For accessing this in a function , I used global keyword.
  Here is the code:</p>
  
  <pre><code>include "Database.php";
  $db=new DataBase();
  
  function getUser()
  {
      $uname=$_SESSION['UNAME'];
      global $db,$uid;
      $result2=$db-&gt;selectUserDetails();
      $result3=$db-&gt;selectUserPermission($uid);
      $table =   constructTable($result2, $result3);
      echo $table;
  }
  </code></pre>
  
  <p>and when i am using that, it is showing an error </p>
  
  <pre><code>"Fatal error:  Call to a member function selectUserDetails() on a non-object 
  in C:\\wamp\\www\\listdetails.php on line 27" 
  </code></pre>
  
  <p>Anyone can tell me a solution.</p>