php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70193 Invalid numeric literal
Submitted: 2015-08-05 11:53 UTC Modified: 2015-08-05 12:53 UTC
From: phpbugs at caspertech dot co dot uk Assigned:
Status: Not a bug Package: Variables related
PHP Version: 7.0.0beta2 OS: Gentoo
Private report: No CVE-ID: None
 [2015-08-05 11:53 UTC] phpbugs at caspertech dot co dot uk
Description:
------------
In some cases, an apparently valid numeric literal is being detected as an invalid numeric literal.

This is a regression since php5.4 - http://3v4l.org/MmCot

It can be fixed by changing the array to:

1, 3, 5, 7, 8, 10, 12

However, I believe this is possibly unintended behaviour (is there any reason not to accept prefixed zeros?)

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

class Test
{
    protected static $months_31 = array( 01, 03, 05, 07, 08, 10, 12 );
}

?>

Expected result:
----------------
No output - I would expect these numeric literals to parse without incident.

Actual result:
--------------
Parse error: Invalid numeric literal in /test.php on line 5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-05 12:53 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2015-08-05 12:53 UTC] nikic@php.net
Numbers starting with 0 are octal literals. 08 is not a valid octal literal, so you get an error now. Previously it was silently treated like 0.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 21:01:42 2019 UTC