如何使用PHP将用户IP转换为部分IP? [英] How do I convert a users IP into a partial IP using PHP?

查看:57
本文介绍了如何使用PHP将用户IP转换为部分IP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户IP为78.64.34.142,我需要一种将用户IP转换为部分IP IE的方法,它会将其转换为78.64。

解决方案

步骤1.要获取客户端的IP,请阅读:

get-client-ip-address-using-php [ ^ ]

步骤2.要从php中的有效IP获取部分ip,请参阅示例代码:

  //   


clientIP包含从步骤1获得的客户端IP


ipPart = explode('

I need a way to convert a users IP into a partial IP IE if the users IP is "78.64.34.142" it'll convert it to "78.64."

解决方案

Step 1. To get the client's ip, read this:
get-client-ip-address-using-php[^]
Step 2. To get the partial ip from a valid ip in php, see example code:

//


clientIP contains the client ip obtained from Step 1


ipPart=explode('.',


这篇关于如何使用PHP将用户IP转换为部分IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆