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

Posted by Rik Wasmus on 01/06/08 18:40

On Sun, 06 Jan 2008 19:26:30 +0100, 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 ;

Will return nothing (empty string) : ''

> echo false+false ;

Will return 0 (cast to integer): '0';

> echo intval(false) ;

Will return 0 (cast to integer): '00';

> echo '"'.false.'"' ;

Will return '""': '00""';

>
> echo true ;

Will return 1: '00""1';

> echo true+true ;

Will return 2: '00""12';

> echo intval(true) ;

Wil return 1: '00""121';

> echo '"'.true.'"' ;

Will return '"1"': '00""121"1"';

> should produce
>
> 000"0"121"1"

No it shouldn't, echo false will not give you a zero. Take a hard look at
the types section in the manual, especially at type juggling.

--
Rik Wasmus

 

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

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