[Solar-talk] bounding zero
Rodrigo Moraes
rodrigo.moraes at gmail.com
Mon Mar 12 10:49:06 PDT 2007
On 3/12/07, Rodrigo Moraes wrote:
> On 3/12/07, Paul M Jones wrote:
> > Can you tell if this is a problem with Solar_Sql, or if it is with PDO?
>
> It seems to be Solar_Sql related, because $val = 0 results in false in
> the comparison if ($val != SOLAR_IGNORE_PARAM).
var_dump($val);
var_dump(SOLAR_IGNORE_PARAM);
var_dump($val != SOLAR_IGNORE_PARAM);
result:
int(0)
string(46) "SOLAR_IGNORE_PARAM3229045f59018ec8305.20058618"
bool(false)
So we can conclude that:
0 = "SOLAR_IGNORE_PARAM3229045f59018ec8305.20058618"
(but I prefer to type just 0, because it is faster :P)
Now, seriously; isn't disturbing that (0 != SOLAR_IGNORE_PARAM) is
false? Antti discovered why:
Cast SOLAR_IGNORE_PARAM3229045f59018ec8305.20058618 to int and you
will have int(0). And PHP will cast to int automatically, resulting in
0 and so ($val != SOLAR_IGNORE_PARAM). is false.
So the solution seems to be include the type checking always: ($val
!== SOLAR_IGNORE_PARAM).
rodrigo
More information about the solar-talk
mailing list