本文介绍了将字符串转换为整数将返回2147483647的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多其他人似乎都遇到了这个问题,但通常与MySQL数据类型有关.

Plenty of others seem to have had this problem, but usually associated with an MySQL datatype.

我正在尝试将String转换为Integer,如下所示:

I'm trying to convert a String to an Integer like this:

$adGroupId  = '5947939396';
$adGroupId  = intval($adGroupId)

但是返回的整数是2147483647,与输入的字符串无关.

However the Integer returned is 2147483647, irrespective of the string input.

推荐答案

该数字太大,无法容纳整数数据类型(如上面所示,最大整数值为2147483647). 将其转换为浮点型将起作用:

That number is too big to fit in an integer data type (the max integer value is 2147483647 as seen above). Converting it to a float instead will work:

$adGroupId  = '5947939396';
$adGroupId  = floatval($adGroupId)

这篇关于将字符串转换为整数将返回2147483647的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 23:37