php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73864 '3.' is considered as a numeric string
Submitted: 2017-01-04 21:44 UTC Modified: 2017-01-06 17:51 UTC
From: mumu at seznam dot cz Assigned: cmb (profile)
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.1.0 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mumu at seznam dot cz
New email:
PHP Version: OS:

 

 [2017-01-04 21:44 UTC] mumu at seznam dot cz
Description:
------------
'3.' is evaluated as a numeric string even it is not a valid number.

Test script:
---------------
<?php

echo '3. ' . (is_numeric('3.') ? 'IS' : 'IS NOT') . ' numeric';

?>

Expected result:
----------------
is_numeric('3.') returns false.

Actual result:
--------------
is_numeric('3.') returns true.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-04 21:48 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2017-01-04 21:48 UTC] requinix@php.net
It is a valid number. Why shouldn't it be?
 [2017-01-06 10:43 UTC] mumu at seznam dot cz
-Status: Feedback +Status: Open
 [2017-01-06 10:43 UTC] mumu at seznam dot cz
I would not expect 3. to be a valid syntax of a number. However, it seems to be valid notation in PHP. Personally, I would be happy if this syntax is not a valid number as it is quite confusing and weird (has no match in real world).
 [2017-01-06 17:51 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: Unknown/Other Function +Package: Scripting Engine problem -Assigned To: +Assigned To: cmb
 [2017-01-06 17:51 UTC] cmb@php.net
> (has no match in real world)

Well, floating point numbers generally do not match the real
world. Anyhow, the valid syntax of float numbers is well
documented[1], so this is not a bug.

[1] <http://php.net/manual/en/language.types.float.php>
 [2017-01-07 06:38 UTC] a at b dot c dot de
A real-world example of "3." results from measuring the circumference and diameter of a circle to one significant digit and taking their ratio (cf. I Kings 7:23).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 04:01:32 2024 UTC