This is an interesting bug because it is related to the way
PHP handles true and false. In PHP null, false, '', and 0
are all equivalent.
The easiest way around this is to never rely on implicit
true or false evaluation. For example, always write code
like if (request::getParameter(x) !== null) - in PHP === and
!=== are extra explicit tests that compare for the literal
evaluation. if (null === 0) will return false, for example.
It is generally good practice to be as explicit as possible
because it makes your code easier to read, however I agree
this is rather confusing, and maybe we should look into
using explicit === or !=== in the Request object.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=1291914
This is an interesting bug because it is related to the way
PHP handles true and false. In PHP null, false, '', and 0
are all equivalent.
The easiest way around this is to never rely on implicit
true or false evaluation. For example, always write code
like if (request::getParameter(x) !== null) - in PHP === and
!=== are extra explicit tests that compare for the literal
evaluation. if (null === 0) will return false, for example.
It is generally good practice to be as explicit as possible
because it makes your code easier to read, however I agree
this is rather confusing, and maybe we should look into
using explicit === or !=== in the Request object.