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 a
I think it is bad practice to return mixed data types. It is possible, as you pointed out, but think about the readability and maintainability of your code. Make sure you comment what you are returning and why, I think that is going to be most important. If you are expecting back an int and you return -1 instead of null, comment that, so you (or someone else) doesn't go crazy trying to figure out what you were trying to do.