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

Pull Requests

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.
 [2019-12-12 15:57 UTC] nospam at mckenzies dot net
This is ridiculous!  Bad regression, from working to PARSE ERROR!  Why not warning or deprecated???
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 16:01:33 2024 UTC