note 68201 deleted from language.types.type-juggling by tularis
| From: | tularis@php.net | Date: | Tue, 05 Jun 2007 09:46:28 +0000 |
| Subject: | note 68201 deleted from language.types.type-juggling by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127222@lists.php.net to get a copy of this message | ||
Note Submitter: frederick_ricaforte at yahoo dot com
----
<?php
// I got a string:
$str= "0000";
var_dump($str);
echo "\\n$str is ".(is_numeric($str)?"numeric":"not numeric");
echo "\\n$str>0 , ".(($str>0)?"yes":"no");
/** take a note of this **/
echo "\\n$str=='000' ,
".(($str=="000")?"yes":"no");
/** endnote **/
echo "\\n$str==0 , ".(($str==0)?"yes":"no");
echo "\\n$str<0 , ".(($str<0)?"yes":"no");
$au = $str*1;
echo "\\n$str*1 is equal to ".$au;
echo "\\n";
var_dump($au);
?>
______________________________
string(4) "0000"
0000 is numeric
0000>0 , no
0000=='000' , yes
0000==0 , yes
0000<0 , no
0000*1 is equal to 0
int(0)
______________________________
0000=='000' , yes
Seems like in type juggling, numeric test has more priority over string comparison.
Frederick Ricaforte