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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 15:01:33 2025 UTC