First a simple example:
function doReturnSomething()
{
// some logic
if ($resultFromLogic) {
return Default_Model_Something;
}
return false;
}
As you can see, this functions returns a model or false. Now, let's call this function from some place else:
$something = doReturnSomething();
No, I want to put a if-statement to check the variable $something. Let's say:
if (false !== $something) {}
or
if ($something instanceof Default_Model_Something) {}
or
...
Is there a "best practice" for this situation to do? Check for false or use instance of. And are there any consequences for that particular way?
Thank is advance!
nullinstead of a bollean, because a)nullis the equivalent of "nothing", which seems to fit here quite well, and b) there may be situations, where the return value should be a boolean and then you cannot distinguish between "nothing"falseand "value"false