php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73990 array key leading zero inconsistent parse error
Submitted: 2017-01-25 10:14 UTC Modified: 2017-01-25 10:49 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: zewy at hotmail dot com Assigned:
Status: Not a bug Package: Compile Failure
PHP Version: 7.1.1 OS: Linux
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: zewy at hotmail dot com
New email:
PHP Version: OS:

 

 [2017-01-25 10:14 UTC] zewy at hotmail dot com
Description:
------------
array key with a leading 0 and any digit except for 8 or 9 will not result in Parse error!

This have bin sens php 7.0+

Test script:
---------------
$a = array(00=>'OK',01=>'OK',02=>'OK',03=>'OK',04=>'OK',05=>'OK',06=>'OK',07=>'OK',10=>'OK',18=>'OK',19=>'OK');
#$b = array(08=>'08',09=>'09',018=>'018',019=>'019');
print_r($a);

Expected result:
----------------
Parse error: Invalid numeric literal in X on line Y

Actual result:
--------------
Array
(
    [0] => OK
    [1] => OK
    [2] => OK
    [3] => OK
    [4] => OK
    [5] => OK
    [6] => OK
    [7] => OK
    [10] => OK
    [18] => OK
    [19] => OK
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-25 10:49 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-01-25 10:49 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

A leading zero means octal, which only uses digits 0-7. In PHP 7 invalid octal numbers became a parse error.
http://php.net/manual/en/language.types.integer.php
https://en.wikipedia.org/wiki/Octal
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC