confused: casting a variable to integer
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

confused: casting a variable to integer

From: Erwin Moller <since_humans_read_this_I_am_spammed_too_much@spamyourself.com>
Date: Tue Nov 29 2005 - 17:55:25 CET

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
Received on Sat Dec 3 04:24:20 2005