1. Create a new PHP document and obtain the IP of the access client. Example:
$cip = $_SERVER['REMOTE_ADDR'];
2. Use echo explicitly Output the IP of the current accessing client for debugging
3. Save the above content and check the IP of the current accessing end. For example, in the example it is local (ie intranet) 127.0. 0.1, where "127." is a characteristic string of the intranet IP
4. Use the strpos() built-in function to determine whether the current customer is from the intranet. Example:
if(strpos($cip,'127.')==0){ echo '当前客户来自(内网):'. $cip; }else{ echo '外网用户:'. $cip; }
5. Save the above file, check the final effect, and determine whether the IP comes from the internal network or the external network
##Note: $_SERVER['REMOTE_ADDR'] is used to obtain the client IP
Recommended tutorial:The above is the detailed content of PHP determines whether the IP is intranet. For more information, please follow other related articles on the PHP Chinese website!