First of all, I got it to work, but am looking for advice on better ways to do it. (Perhaps one way is faster than another?) If this belongs in the Design section, I am sorry: can a moderator please move it then?
I have a function foo() that returns either an integer (greater than or equal to zero) or false on an error. I used the following line to call it, and die() on an error (returned false):
Code: Select all
$bar = foo() or die();I have two possible fixes for this. The first is:
Code: Select all
is_numeric($bar = foo()) or die();The second one I've come up with is:
Code: Select all
($bar = foo()) !== false or die();Code: Select all
($bar = foo()) === true or die();Or do you perhaps know a better way to do this?
Thanks in advance,
Wouther