When returnign values in php is it considered good or bad practivce to return mixed data types. Im working on a project where i am constantly being faced with methods that wither return and id number or null. Im handling the null value by checking for null and returning -1 if is null.
Another situation where i find myself in a lot is where a method should do something and return a string. But sometimes its not possible to return the string as it wasnt found or an exception happened. Whats best 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??
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 be on success. But... is there a defacto best practice when it comes to this? I mean, what do programmers in otger languages do i.e. java and c++ etc in these situations?