title: Mixed Results for Class Method
body: <p>I use PHP with the Codeigniter framework, and  often have methods in my classes that return an array of values.  It makes things simpler in my views if there are no records returned, that the method return FALSE or NULL, rather than returning an empty array.  In my views I can just have something like:</p>
  
  <pre><code>&lt;?php if($abc_array) : ?&gt;
  
  // loop through the array, etc.
  
  &lt;?php else : ?&gt;
  
  // show some message
  
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>If I return an empty array, I end up including something like the following in the views:</p>
  
  <pre><code>&lt;?php if(is_array($abc_array) AND count($abc_array) &gt; 0) : ?&gt;
  </code></pre>
  
  <p>I guess this is kind of a trivial example, but I'm mainly wondering if it is considered bad practice to have class methods return mixed result types.  What about if a mysql error is somehow generated in the class and caught, should I have the returned result types something like:</p>
  
  <p>FALSE (on some type of error)</p>
  
  <p>Empty Array (if no results were returned)</p>
  
  <p>Array of Results (results were returned)</p>
  
  <p>I'm just trying to figure out what the best practices are for this kind of thing...</p>