Weird output, when number starts with 0

后端 未结 1 1487
闹比i
闹比i 2021-01-24 17:02

1. script:

$num = \"00445790\";
echo $num;

returns:

00445790

2. script

$num = 00445790;
echo          


        
相关标签:
1条回答
  • 2021-01-24 17:42

    Integers that start with zero are consider octal. Because octal integers only use numbers from 0 to 8 everything from the 9 on are ignored.

    So 00445790 becomes 004457 which is 2351 in decimal.

    0 讨论(0)
提交回复
热议问题