$s){ $ip += $s* pow(256,3-$i); } echo 'Convert to decimal value:'.$ip"/> $s){ $ip += $s* pow(256,3-$i); } echo 'Convert to decimal value:'.$ip">

Home  >  Article  >  Backend Development  >  Download Innocence IP database Application of Innocence IP database Convert IP address to decimal

Download Innocence IP database Application of Innocence IP database Convert IP address to decimal

WBOY
WBOYOriginal
2016-07-29 08:40:061304browse

It turns out that you need to convert the IP to decimal

Copy the code The code is as follows:


$ip = $_SERVER['REMOTE_ADDR'];
echo 'Your IP:'.$ip.'
';
$ip_arr = explode(".",$ip);
$ip = 0;
foreach($ip_arr as $i=>$s){
$ip += $s*pow(256 ,3-$i);
}
echo 'Convert to decimal value:'.$ip.'
';


//The result is your IP: 127.0.0.1
Convert to decimal value: 2130706433

The above introduces the innocent ip database download, the application of innocent IP database, and the conversion of IP address into decimal, including the content of innocent ip database download. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn