php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73172 parse error: Invalid numeric literal
Submitted: 2016-09-26 07:44 UTC Modified: 2016-09-26 17:33 UTC
From: elbazmichael92 at gmail dot com Assigned: ab (profile)
Status: Closed Package: *General Issues
PHP Version: 7.0.11 OS: Windows 7
Private report: No CVE-ID: None
 [2016-09-26 07:44 UTC] elbazmichael92 at gmail dot com
Description:
------------
On php cli only (all version > 7) this code will throw parse error: Invalid numeric literal the problem only with int parameter greater than 2147483647 (unsigned int)

function test($a, $x, $y){
  return;
}
test('test', 2147483648, 'test');  

the only solution i found is to add space after the int parameter:

test('test', 2147483648 , 'test');  

i found this bug using the phpseclib lib class SFTP line 1294.

Test script:
---------------
function test($a, $x, $y){
  return;
}
test('test', 2147483648, 'test'); 

Expected result:
----------------
running without error

Actual result:
--------------
Parse error: Invalid numeric literal

Patches

Invalid_parsing (last revision 2016-09-26 07:49 UTC by elbazmichael92 at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-26 08:14 UTC] elbazmichael92 at gmail dot com
this is happen only with this configuration setlocale(LC_ALL, 'fr_FR.utf8', 'fra');
 [2016-09-26 09:01 UTC] elbazmichael92 at gmail dot com
to reproduc the bug you need use two file:
a.php 
<?php 
setlocale(LC_ALL, 'fr_FR.utf8', 'fra'); //LC_ALL
require 'patch.php';

then in patch.php
<?php
function t($a, $x, $y){
  return;
}
t('test', 2147483649, 'test');

the probleme is with the setlocal function in cli mode and php > 7 version its not happen with previous version.
 [2016-09-26 09:46 UTC] nikic@php.net
It looks like we're using strtod compiled with USE_LOCALE, something we probably shouldn't be doing.
 [2016-09-26 16:56 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=39e599170532f64fd433dd68aa79bc0dcbda4689
Log: Fixed bug #73172 parse error: Invalid numeric literal
 [2016-09-26 16:56 UTC] ab@php.net
-Status: Open +Status: Closed
 [2016-09-26 17:33 UTC] ab@php.net
-Assigned To: +Assigned To: ab
 [2016-09-26 17:33 UTC] ab@php.net
Nice catch, Nikita! In PHP 5 strtod implementation the locale is simply ignored, but in the upgraded strtod code it handles the decimal point. But strings from PHP should only be accepted with '.'.

@elbazmichael92, please check the latest http://windows.php.net/snapshots/ .

Thanks.
 [2016-10-17 10:07 UTC] bwoebi@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=39e599170532f64fd433dd68aa79bc0dcbda4689
Log: Fixed bug #73172 parse error: Invalid numeric literal
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 00:01:27 2024 UTC