confused: casting a variable to integer
- From: Erwin Moller <since_humans_read_this_I_am_spammed_too_much@xxxxxxxxxxxxxxxx>
- Date: Tue, 29 Nov 2005 17:55:25 +0100
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
.
- Follow-Ups:
- Re: confused: casting a variable to integer
- From: Sean
- Re: confused: casting a variable to integer
- From: Justin Koivisto
- Re: confused: casting a variable to integer
- Prev by Date: Learning PHP and MySql
- Next by Date: Re: the Visitor Design Pattern
- Previous by thread: Learning PHP and MySql
- Next by thread: Re: confused: casting a variable to integer
- Index(es):
Relevant Pages
|