php - why there is a difference between below given output? -


$y = 07; echo 'y: '.$y; // result 7 $y = 08; echo 'y: '.$y; // result 0 

view demo

:edit:

one more similar

$y = 013; echo $y + 5; //this result in 16 

i can not figure out how ans 16? can 1 help?

part 1

the rules parsing explained in integers documentation.

in php number starting 0 assumed in octal. because 08 in octal isn't valid getting 0.

part 2

the same issue in play, 013 in octal 11 in decimal , 11 + 5 = 16


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -