Reply to Re: Passing Boolean to a Function

Your name:

Reply:


Posted by Rik on 07/11/06 13:38

David Haynes wrote:
> Rik wrote:
>>> $row['isarchived'] is already a 0/1 value (Tinyint(1)), so really
>>> the (bool) cast is a no-op. My bad. You could just use $isArchived =
>>> $row['isarchived']
>>
>> What do you mean by no-op? I'm no native speaker, please explain.
>> And already 0/1? 0/1 is an integer, not a boolean.
>
> Due to the loose type association false (boolean) == 0 (integer).
> Similarly, true (boolean) == (not) 0 (integer)
>
> So, given that a Tinyint(1) can only return 0 and 1 this has a direct
> 1:1 mapping through the implied type casting of PHP to false and true.
>
> That's what I meant by no-op (PHP will handle it for you)

It does in most cases, however, if one states:"I would translate the 0/1
from MySQL into true/false at the lowest level I could.", one provides an
answer :-).

Grtz,
--
Rik Wasmus

[Back to original 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

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