Home >Backend Development >PHP Tutorial >Application of Innocence IP Database Converting IP Address to Decimal_PHP Tutorial

Application of Innocence IP Database Converting IP Address to Decimal_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 15:45:581176browse

It turns out that you need to convert the IP into 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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320207.htmlTechArticleIt turns out that you need to convert the IP into decimal and copy the code as follows: $ip = $_SERVER['REMOTE_ADDR']; echo 'Your IP:'.$ip.'br /'; $ip_arr = explode(".",$ip); $ip = 0; foreach($ip_arr as $i...
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