|
Posted by Tim Streater on 01/06/08 18:31
In article <gn62o3d3bannrpv05tu9ch7a0mnn2cupok@4ax.com>,
A Bit Narked <anonymous@example.com> wrote:
> 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?
What I get are the constants/terms/reserved words true and false with
those values. What else do I need? There is no need to know what values
these equate to, if any.
Navigation:
[Reply to this message]
|