title: PHP - Calling a class function from another class
body: <p>I am trying to create an error handling class that can be called from other classes, however when I call a function within the error handling class from another class, I get the following error: </p>
  
  <blockquote>
    <p><strong>Fatal error:</strong> Call to a member function fetch_error_text() on null in (filepath_here) on line 361</p>
  </blockquote>
  
  <p>Here is the code I have so far:</p>
  
  <pre><code>global $errhandle_func_call;    
  class ERR_HANDLE
  {
     public function __construct()
     {
     }
  
     public function fetch_error_text($err_text)
     {
         $err_text_display = $return_msg[$err_text];
         return "&lt;h4&gt;" . $err_text_display . "&lt;/h4&gt;";
     }
  }
  
  $errhandle_func_call = new ERR_HANDLE();
  
  class BASKET
  {
      public function view_basket()
      {
          //some_code_here
          if($query-&gt;num_rows &lt; 1)
          {
              echo $errhandle_func_call-&gt;fetch_error_text("basket_empty");
          }
      }
  }
  </code></pre>
  
  <p>Thanks.</p>