echo vs echo intval PHP

前端 未结 3 754
小鲜肉
小鲜肉 2020-12-21 14:25

Please can some one explain the result differences below

echo intval(1e10); 

Output 1410065408



        
3条回答
  •  爱一瞬间的悲伤
    2020-12-21 14:32

    A signed integer has a maximum value. On 32-bit systems, that's 2^16 or 2147483647. When intval-ing a number that's larger, it will overflow. The value you found can also calculated:

    php > echo 1e10 % (2147483647);
    1410065408
    

提交回复
热议问题