php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67719 is_numeric treats leading and trailing spaces differently
Submitted: 2014-07-30 15:22 UTC Modified: 2020-03-17 09:04 UTC
Votes:11
Avg. Score:3.1 ± 1.3
Reproduced:6 of 8 (75.0%)
Same Version:2 (33.3%)
Same OS:3 (50.0%)
From: bichinhoverde at spwinternet dot com dot br Assigned: ajf (profile)
Status: Suspended Package: Variables related
PHP Version: 5.5.15 OS: Linux and Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
35 + 19 = ?
Subscribe to this entry?

 
 [2014-07-30 15:22 UTC] bichinhoverde at spwinternet dot com dot br
Description:
------------
is_numeric(" 1") is true
is_numeric("1 ") is false



Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-02-12 06:48 UTC] progr-d at yandex dot ru
This bug not fixed in php7.3.1
 [2019-02-12 07:59 UTC] nikic@php.net
-Assigned To: +Assigned To: ajf
 [2020-03-17 09:03 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=349477
Log: is_numeric() accepts leading whitespace

Cf. bug #67719.
 [2020-03-17 09:04 UTC] cmb@php.net
-Status: Assigned +Status: Suspended -Type: Bug +Type: Feature/Change Request -Package: *Math Functions +Package: Variables related
 [2020-03-17 09:04 UTC] cmb@php.net
Well, this is not really a bug, but rather common PHP behavior
regarding numeric strings[1].  Thus, I'm changing to feature
request and suspend the ticket, waiting on the outcome of the
"Permit trailing whitespace in numeric strings" RFC[2].

[1] <https://github.com/php/php-langspec/blob/master/spec/05-types.md#the-string-type>
[2] <https://wiki.php.net/rfc/trailing_whitespace_numerics>
 [2020-03-17 10:26 UTC] mumumu@php.net
Automatic comment from SVN on behalf of mumumu
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=349480
Log: is_numeric() accepts leading whitespace

Cf. bug #67719.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 05:01:29 2024 UTC