Doc #79111 [Opn->Ver]: is_numeric documentation utterly incomplete
| From: | cmb@php.net | Date: | Mon, 13 Jan 2020 17:17:03 +0000 |
| Subject: | Doc #79111 [Opn->Ver]: is_numeric documentation utterly incomplete | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17200@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79111&edit=1
ID: 79111
Updated by: cmb@php.net
Reported by: php4fan at gmail dot com
Summary: is_numeric documentation utterly incomplete
-Status: Open
+Status: Verified
Type: Documentation Problem
Package: Variables related
Operating System: all
PHP Version: Irrelevant
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2020-01-13 17:16:44] cmb@php.net
See also <https://wiki.php.net/rfc/trailing_whitespace_numerics>.
------------------------------------------------------------------------
[2020-01-13 16:07:00] php4fan at gmail dot com
Description:
------------
---
From manual page: https://php.net/function.is-numeric
---
I found out to my surprise that is_numeric(" 3") returns true, but is_numeric("3
") returns false. Spaces at the beginning of a string have no effect; spaces at the end do,
making the string not numeric.
Assuming that's the expected behavior, that's far from obvious and should be documented.
The docs say:
"Numeric strings consist of optional sign, any number of digits, optional decimal part and
optional exponential part."
There's no mention whatsoever of spaces. From that description, taken literally, I'd
expect a space at the beginning to ALSO be considered non-numeric. Short of that, I'd expect
spaces to be either ignored both at the beginning and end or neither.
Test script:
---------------
echo is_numeric("3")?"Yes\n":"no\n";
echo is_numeric(" 3")?"Yes\n":"no\n";
echo is_numeric("3 ")?"Yes\n":"no\n";
Expected result:
----------------
documentation should be exhaustive
Actual result:
--------------
documentation doesn't document the behavior properly.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79111&edit=1