note 81951 added to function.round
| From: | kjohnson at zootweb dot com | Date: | Thu, 20 Mar 2008 20:29:40 +0000 |
| Subject: | note 81951 added to function.round | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137243@lists.php.net to get a copy of this message | ||
Regarding the change of behavior where round now returns certain values in exponential notation,
here's a second way this can bite you.
If you have field validation code like below, this will falsely indicate an error when the consumer
enters one of the "special" values for income, e.g., 1200000, which is returned as
"1.2E+6":
if(!ereg("^[0-9]{1,10}$", round($_POST['income']))) {
$errors .= "<li>Income should be whole dollars only (10 digits max).</li>";
}
Needless to say, not a good user experience.
----
Server IP: 208.69.120.35
Probable Submitter: 12.7.177.130
----
Manual Page -- http://www.php.net/manual/en/function.round.php
Edit -- https://master.php.net/note/edit/81951
Del: integrated -- https://master.php.net/note/delete/81951/integrated
Del: useless -- https://master.php.net/note/delete/81951/useless
Del: bad code -- https://master.php.net/note/delete/81951/bad+code
Del: spam -- https://master.php.net/note/delete/81951/spam
Del: non-english -- https://master.php.net/note/delete/81951/non-english
Del: in docs -- https://master.php.net/note/delete/81951/in+docs
Del: other reasons-- https://master.php.net/note/delete/81951
Reject -- https://master.php.net/note/reject/81951
Search -- https://master.php.net/manage/user-notes.php