|
Posted by A Bit Narked on 01/06/08 18:26
Can someone explain the rationale - if there is one - behind
treating the constants TRUE and FALSE differently?
echo false ;
echo false+false ;
echo intval(false) ;
echo '"'.false.'"' ;
echo true ;
echo true+true ;
echo intval(true) ;
echo '"'.true.'"' ;
should produce
000"0"121"1"
but instead produces
00""121"1"
In other words, the only way to output the underlying zero or use
it in a string is to use 'false+false' or pass it through
intval(). No such tricks are required to get at the 1 that
underlies true.
The whole idea of symbolic constants is that they are always
replaced by the underlying value during translation, and thus
*anywhere* you would otherwise have to use some obscure "magic
number" such as 191, you can use a symbolic constant that makes
sense in your context, such as TOTAL_NATIONS.
Exactly what we get -or php gets- out of php breaking this rule
was not explained to me by the person who marked my bug report
'bogus'. Can someone here explain it?
Navigation:
[Reply to this message]
|