|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-02-12 07:32 UTC] torben at cvs dot php dot net
[2000-02-13 13:10 UTC] danny at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
I'm trying to tell the difference between a string value and an integer value -- not a string type variable and an integer type variable. I.e., if a string type variable contains the value "503", I want to consider it an integer. So, I use intval(), figuring that if the intval() of a variable is the same as the value of the variable, then the variable has an integer value. For example, if $x = "503", then intval($x) = 503. So, $x == intval($x) and I consider it an integer. If $x = "this is a test", then intval($x) is 0. Since $x != intval($x), I don't consider it an integer. Here's the part I don't understand: <? $x = "this is a test"; echo "<p>\$x = " . $x; echo "<p>intval(\$x) = " . intval($x); if ($x == intval($x)) { echo "<p>\$x is an int"; } ?> The output of this script is: $x = this is a test intval($x) = 0 $x is an int How the heck is $x == intval($x) if $x = "this is a test" and intval($x) = 0?