Home > Backend Development > PHP Tutorial > 纯真IP数据库的应用 IP地址转化成十进制_php实例

纯真IP数据库的应用 IP地址转化成十进制_php实例

WBOY
Release: 2016-05-17 09:32:01
Original
897 people have browsed it

原来是需要把IP转成十进制

复制代码 代码如下:

$ip = $_SERVER['REMOTE_ADDR'];
echo '你的IP:'.$ip.'
';
$ip_arr = explode(".",$ip);
$ip = 0;
foreach($ip_arr as $i=>$s){
$ip += $s*pow(256,3-$i);
}
echo '转十进制值:'.$ip.'
';

//结果你的IP:127.0.0.1
转十进制值:2130706433
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template