Why some non-numeric object could be 0? From your code sample, it is apparent that
$loginUser
is an instance of some class (it has
execute
method, for example). So, you need this:
http://php.net/manual/en/function.is-null.php[
^].
Note that the change in the
if
statement would not make your code correct. You are thinking about a check which is would be too late. For example, you are trying to call
$loginUser->execute
before the check, but in case where
$loginUser
is null, you would be dereferencing null object, which would throw the exception.
—SA