加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

探讨PHP函数ip2long转换IP时数值太大产生负数的解决方法

发布时间:2020-12-13 06:19:58 所属栏目:PHP教程 来源:网络整理
导读:【造成原因】:Because PHP's integer type is signed,and many IP addresses will result in negative integers.【解决办法】:其官方手册中提到,可以“you need to use the "%u" formatter of bindec ( decbin ( ip2long ( 'IP地址' ) ) ); echo ip2long(

【造成原因】:Because PHP's integer type is signed,and many IP addresses will result in negative integers. 【解决办法】:其官方手册中提到,可以“you need to use the "%u" formatter of bindec(

decbin

(

ip2long

( 'IP地址' ) ) );

echo ip2long($strIp); //此时输出的-1233780736 echo '
'; echo bindec( decbin( ip2long( $strIp ) ) ); // 输出3061186560,与MySQL函数输出一致~

number

( string $binary_string ); //二进制转换为十进制 string

( int $number ); //十进制转换为二进制

以上这篇探讨PHP函数ip2long转换IP时数值太大产生负数的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读