title: php returning mixed data types - good or bad
body: <p>When returning values in php, is it considered good or bad practice to return mixed data types.  I'm working on a project where I am constantly faced with methods that return an id number or <code>null</code>.  I'm handling the <code>null</code> value by checking for <code>null</code> and returning <code>-1</code> if it is <code>null</code>.</p>
  
  <p>Another situation I find myself in a lot is where a method should do something and return a string. But sometimes it's not possible to return the string as it wasn't found or an exception happened. What's the best thing to do here? Return a string like 'failed' or something?  This then creates a string coupling between methods, I think, as the calling method has to know exactly the string failure message to check for??</p>
  
  <p>EDIT:  OK there are a few different opinions already.  I like the idea of returning false on failure and the actual result whatever its data type is on success.  But... is there a defacto best practice when it comes to this?  I mean, what do programmers in other languages do i.e. java and c++ etc in these situations?</p>