You are here: TRUE and FALSE are treated differently « PHP Programming Language « IT news, forums, messages
TRUE and FALSE are treated differently

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация