The conversion principle assumes that IP is w x y z, and the formula for converting IP address into integer is intip = * * * w+* * x+* y+z * Y+Z.
The conversion method from PHP to PHP is relatively simple. It has two built-in functions, int ip long (string $ip_address) and string long IP (string $ prop _ address), which can be directly called and used ~
The conversion custom functions of Asp are as follows |? Description: Convert IP to int number? | |? Author: abandonship | ~ ~ Function IP num (Byval Strip) Dim Nindex Dim Arrep Arrep = Split (Strip "") for Nindex = To If Not Nindex = Then Arrep (Nindex) = arrip(nindex)*(^(nindex))end if nip = nip+arrip(nindex)next IP num = nip end function |? Description: Convert integers to IP? | |? Author: abandonship | ~ ~ Function numip (byvalnip) dimstrip dimntemp dimindex for nindex = tostep? nTemp = Int(nIP / ( ^ nIndex))? Strip = strip & amp ""? Nip = nip (ntemp * (nindex)) Next strip = left (strip length (strip)) Num IP = strip end function.
The conversion custom function of MsSQL is as follows:/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *? Convert IP into int number |? *? Code created by abandonship|? * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */CREATE FUNCTION[dbo][ippoint](@ strIp varchar()? ) return to bigint? As? BEGIN declare @nIp bigint set @nIp =? Choice? @ nIp = @ nIp+LEFT(@ strIp charindex(@ strIp+)* Id from(select Id = cast(* * * as bigint)union all select * * union all select * union all select? ) as a t? Return (@nIp) to end? /*************************************************************** ? *? Convert int number into IP |? *? Code created by abandonship|? * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */CREATE FUNCTION[dbo][intto IP](? @nIp bigint? ) returns varchar ()? As? BEGIN declare @ strIp varchar()set @ strIp = select? @ strIp = @ strip++ cast(@ nIp/ID as varchar)@ nIp = @ nIp % ID? from(select ID = cast(* * * as bigint)union all select * * union all select * union all select? ) returns as t (stuff(@strIp))? End?
Lishi Xinzhi/Article/program/PHP/20 13 1 1/2 1328