title: PHP: catching a fatal error (call to member function on a non-object)
body: <p>Sometimes, my script cannot read output by a server and the following error occurs:</p>
  
  <p><code>PHP Fatal error:  Call to a member function somefun() on a non-object</code></p>
  
  <p>This is not something that can't be fixed on my end but this causes my script to crash. Is there a way I can create a function that gets run when this particular error occurs? I don't think it's practical to make a try-catch or similar because I would have to find every instance where a member function gets called and test whether the object exists or not (several thousand). </p>