title: Objects and error handling in PHP
body: <p>What's the best practice to handle errors if using objects?</p>
  
  <p><strong>A)</strong> Before the method of object is called and not even getting to execute method if there's some error, or</p>
  
  <p><strong>B)</strong> Just pass parameters and perform error checking in method itself, returning error code or something.</p>
  
  <p>Please pick your option and short description, why?</p>
  
  <p>Thanks orlandu63, it is good practice, but what about non-fatal errors, such as user should provide a title for something, and he/she didn't?</p>
  
  <pre><code>class Sample {    
  
  var $err_no_title = 1;
  
  function createNewRecord ($title) {
         if (!$title) return $this-&gt;err_no_title;
      }
  }
  </code></pre>
  
  <p>Or use exceptions for these kind of errors also?</p>