note 82199 added to function.is-float
| From: | kshegunov at gmail dot com | Date: | Mon, 31 Mar 2008 21:32:24 +0000 |
| Subject: | note 82199 added to function.is-float | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137798@lists.php.net to get a copy of this message | ||
As celelibi at gmail dot com stated, is_float checks ONLY the type of the variable not the data it
holds!
If you want to check if string represent a floating point value use the following regular expression
and not is_float(),
or poorly written custom functions.
/^[+-]?(([0-9]+)|([0-9]*\.[0-9]+|[0-9]+\.[0-9]*)|
(([0-9]+|([0-9]*\.[0-9]+|[0-9]+\.[0-9]*))[eE][+-]?[0-9]+))$/
----
Server IP: 217.75.128.29
Probable Submitter: 78.90.43.45
----
Manual Page -- http://www.php.net/manual/en/function.is-float.php
Edit -- https://master.php.net/note/edit/82199
Del: integrated -- https://master.php.net/note/delete/82199/integrated
Del: useless -- https://master.php.net/note/delete/82199/useless
Del: bad code -- https://master.php.net/note/delete/82199/bad+code
Del: spam -- https://master.php.net/note/delete/82199/spam
Del: non-english -- https://master.php.net/note/delete/82199/non-english
Del: in docs -- https://master.php.net/note/delete/82199/in+docs
Del: other reasons-- https://master.php.net/note/delete/82199
Reject -- https://master.php.net/note/reject/82199
Search -- https://master.php.net/manage/user-notes.php