You are here: Re: confused: casting a variable to integer « PHP Programming Language « IT news, forums, messages
Re: confused: casting a variable to integer

Posted by Justin Koivisto on 11/29/05 22:34

Sean wrote:
> See the differece if you use ===
>
> <?
> $name="henk";
>
> echo "\$name=$name <br>";
> echo "(int)\$name=".(int)$name."<br>";
>
> if ($name === (int)$name){
> echo "equal";
> } else {
> echo "Not equal";
> }
>
> ?>
>
> http://php.net/operators.comparison
>

But be careful with this...

$i="4";
if($i === intval($i)){
// this will not happen
}

Also keep in mind that values that are supplied via _GET, _POST, _COOKIE
are strings, not their representative types...

Therefore:

call page: page.php?i=4
if($_GET['i'] === intval($_GET['i'])){
// this will not happen
}

--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com

 

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

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