Page 1 of 1

How PHP is getting this result?

Posted: Wed Feb 13, 2008 6:40 am
by BornForCode
Hello a test scenario fro ZCE:

Code: Select all

 
$y = 08;
$y += 15;
echo $y;
 
Running this code gives 15, when i was expecting 23, why this happens?

Re: How PHP is getting this result?

Posted: Wed Feb 13, 2008 7:51 am
by Mordred
Numbers starting with 0 are octal.

8 = 8
08 = 0
10 = 10
010 = 8