Doc #79111 [Ver->Csd]: is_numeric documentation utterly incomplete
| From: | git@php.net | Date: | Thu, 02 Dec 2021 17:56:28 +0000 |
| Subject: | Doc #79111 [Ver->Csd]: is_numeric documentation utterly incomplete | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-19353@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: git@php.net
Reported by: php4fan at gmail dot com
Summary: is_numeric documentation utterly incomplete
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: Variables related
Operating System: all
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of deleugpn (author) and cmb69 (committer)
Revision: https://github.com/php/doc-en/commit/ff054fcb4e0c795093255f1e71be2cae68fc6284
Log: Fix #79111: is_numeric documentation utterly incomplete
Previous Comments:
------------------------------------------------------------------------
[2021-08-22 17:41:14] deleugyn+php at gmail dot com
https://github.com/php/doc-en/pull/870
------------------------------------------------------------------------
[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