不看不知道一看吓一跳啊,在ip转换中在php中居然有函数,可以把ip转换整数,同样也要反过来转换,实例代码如下:
$ip="127.0.0.1"; //定义ip地址 $long=ip2long($ip); //转换ip地址为整数 if($long==-1||$long===false) //如果执行错误 { echo 'invalid ip, please try again'; //输出错误信息 } else { echo $ip . "n"; //192.0.26.166 echo "<br>"; echo $long . "n"; // -1073732954 printf("%un", ip2long($ip)); // 3221234342 } // $ip="127.0.0.1"; //定义ip地址 $long=ip2long($ip); //转换ip地址为整数 if($long==-1||$long===false) //如果执行错误 { echo 'invalid ip, please try again'; //输出错误信息 } else { echo $ip . "n"; //192.0.26.166 echo "<br>"; echo $long . "n"; // -1073732954 printf("%un", ip2long($ip)); // 3221234342 } //再给一个常用字实例 $number="2130706433"; //定义数值 $ip=long2ip($number); //转换为ip地址形式:127.0.0.1 echo $ip;
本文地址:
转载随意,但请附上文章地址:-)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
