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

Posted by Erwin Moller on 11/29/05 18:55

Hi group,

Maybe I should stop working because this seems soo basic.
I almost feel ashamed to ask, but here we go.
:-/

Consider the following script:

<?
$name="henk";

echo "\$name=$name <br>";
echo "(int)\$name=".(int)$name."<br>";

if ($name == (int)$name){
echo "equal";
} else {
echo "Not equal";
}
?>

produces:
-----------------
$name=henk
(int)$name=0
equal
------------------

What am I missing here?

Is PHP casting the string "henk" to 0 somehow?

Regards,
Erwin Moller

 

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

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