php: ip2long returning negative val

后端 未结 6 846
灰色年华
灰色年华 2020-12-30 04:18
function ip_address_to_number($IPaddress) { 
     if(!$IPaddress) {
      return false;
     } else {
      $ips = split(\'\\.\',$IPaddress);
      return($ips[3] +          


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-12-30 05:04

    Try this instead:

    $ip = sprintf('%u', ip2long($_SERVER['REMOTE_ADDR']));
    

    sprintf will then write it as an unsigned integer.

提交回复
热议问题