Mobile phone number modulo, string to long integer

Sometimes it is necessary to convert the mobile phone number into an integer calculation, if it is a string, the calculation is wrong.

But the phone number is 11 digits, direct (int) or (integer) will overflow because it exceeds the boundary.

Int can't be float. .


$num = (float)$phone_num % 99 + 1;


$phone_num = $phone_num +0;
$num = $phone_num % 99 + 1;

当浮点类型过大会出现负数等问题,如下即可解决
$num = intval(fmod(floatval($phone_num), 99));

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325940020&siteId=291194637