Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

echo vs echo intval PHP

Please can some one explain the result differences below

echo intval(1e10); 

Output 1410065408

echo 1e10; 

Output 10000000000

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...