$y = 07;
echo 'Y: '.$y; // result is 7
$y = 08;
echo 'Y: '.$y; // result is 0
开发者_JAVA百科
view demo
:EDIT:
One more similar to that
$y = 013;
echo $y + 5; //this result in 16
I can not figure it out how its ans is 16? Can any one help?
Part 1
The rules for parsing are explained in the Integers Documentation.
In PHP a number starting with a 0 is a assumed to be in Octal. Because 08 in Octal isn't valid you are getting 0.
Part 2
The same issue is in play, 013 in Octal is 11 in Decimal and 11 + 5 = 16
In php integer variable is taken Octal.
http://www.ascii.cl/conversion.htm
show This link useful for you.i think.
精彩评论