You are here: Re: Passing Boolean to a Function « PHP Programming Language « IT news, forums, messages
Re: Passing Boolean to a Function

Posted by David Haynes on 07/11/06 10:16

Rik wrote:
> David Haynes wrote:
>> $result = mysqli_query($sql);
>> while( $row = mysql_fetch_assoc($result) ) {
>> $isArchived = $row['is_archived'] ? true : false;
>> ...
>> }
>
>
> $isArchived = (bool)$row['isarchived'];
> it's shorter, and by using $row['is_archived'] ? you're already evaluating
> the boolean value.
>
>
> http://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
>
> Grtz,

Rik,
$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']

-david-

 

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

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