php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30065 integers with leading 0
Submitted: 2004-09-12 00:44 UTC Modified: 2004-09-12 06:59 UTC
From: agapater at yahoo dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.0.0 OS: windows xp
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: agapater at yahoo dot com
New email:
PHP Version: OS:

 

 [2004-09-12 00:44 UTC] agapater at yahoo dot com
Description:
------------
sometimes php doesn't seem to consider zeros in front of an integer, (like 01 == 1, 02 == 2) but sometimes the results are unexpected.

Reproduce code:
---------------
$numbers = array(01,02,03,04,05,06,07,08,09,10,001,002,003,004,005,006,007,008,009,010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 0001, 0002, 0003, 0004, 0005, 0006, 0007, 0008, 0009, 00010);
foreach($numbers as $number) print $number.",";

Expected result:
----------------
1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 16,17,18,19,20,1,2,3,4,5,6,7,8,9,10,

Actual result:
--------------
1,2,3,4,5,6,7,0,0,10,1,2,3,4,5,6,7,0,0,8,9,10,11,12,13,14,15,1,1,16,1,2,3,4,5,6,7,0,0,8,

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-12 00:48 UTC] eru@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

Congratulations, you have discovered the notation for handling octal numbers ;-)

(see http://www.php.net/manual/en/language.types.integer.php)

 [2004-09-12 01:04 UTC] agapater at yahoo dot com
Thank you for your quick answer.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 21:01:27 2024 UTC