php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65339 08 and 8 are not the same and 09 and 9 are also not the same
Submitted: 2013-07-25 20:42 UTC Modified: 2013-07-26 01:25 UTC
From: dondanielsgh at yahoo dot com Assigned:
Status: Not a bug Package: PHP options/info functions
PHP Version: 5.5.1 OS: windows
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: dondanielsgh at yahoo dot com
New email:
PHP Version: OS:

 

 [2013-07-25 20:42 UTC] dondanielsgh at yahoo dot com
Description:
------------
$x = 07;
if($x == 7){
echo 'correct';
}else{
echo 'they are not the same';
}

$x = 08;
if($x == 8){
echo 'correct';
}else{
echo 'they are not the same';
}

$x = 09;
if($x == 9){
echo 'correct';
}else{
echo 'they are not the same';
}

Test script:
---------------
$x = 07;
if($x == 7){
echo 'correct';
}else{
echo 'they are not the same';
}

$x = 08;
if($x == 8){
echo 'correct';
}else{
echo 'they are not the same';
}

$x = 09;
if($x == 9){
echo 'correct';
}else{
echo 'they are not the same';
}

Expected result:
----------------
$x = 08;
if($x == 8){
echo 'correct';
}else{
echo 'they are not the same';
}

$x = 09;
if($x == 9){
echo 'correct';
}else{
echo 'they are not the same';
}

the results should be correct.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-26 00:03 UTC] cmbecker69 at gmx dot de
| the results should be correct.

Actually the results are correct.  07, 08 and 09 are treated as 
octal integers, and the documentation on integers
(<http://www.php.net/manual/en/language.types.integer.php>) states:

| If an invalid digit is given in an octal integer (i.e. 8 or 9),
| the rest of the number is ignored.
 [2013-07-26 01:25 UTC] felipe@php.net
-Status: Open +Status: Not a bug
 [2013-07-26 01:25 UTC] felipe@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


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 03 14:01:30 2025 UTC