note 47643 added to function.settype
| From: | php-general at lists dot php dot net | Date: | Tue, 23 Nov 2004 21:34:48 +0000 |
| Subject: | note 47643 added to function.settype | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-80941@lists.php.net to get a copy of this message | ||
in PHP3 converting a string to any number results in the value becoming 0. To check if a string
represents a number try this:
<PRE>
$test = "0001";
$testcp = $test;
settype($testcp,"double");
if (strval($testcp) === $test) {
echo("\$test is a number");
} else {
echo ("\$test is not a number");
}
</PRE>
----
Manual Page -- http://www.php.net/manual/en/function.settype.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47643
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47643&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47643&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47643&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47643&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47643&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47643&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47643&report=yes
Search -- http://master.php.net/manage/user-notes.php