Assume that there is an IP address range of 192.168.0.0~192.168.0.255. The code that only allows access to this IP segment is as follows:
Copy the code The code is as follows:
$IP = $_SERVER['REMOTE_ADDR'];
$from = strcmp($IP,'192.168.0.0');
$to = strcmp($ IP,'192.168.0.255');
if (!($from >= 0 && $to <= 0))
echo "Access Denied";
else
echo "Homepage ";
?>
Process-wise, this code first captures the visitor's IP address, and then determines whether the IP address meets the access conditions. If it matches, the page will be output normally, otherwise access will be denied.
According to this, if the user IP address meets the requirements, simply output or include the page file. The file contains the following code:
Copy code The code is as follows:
if (!($from >= 0 && $to <= 0))
echo "Access Denied";
else
include('homepage.html')";
?>
Of course, you can also jump to different pages according to the judgment results. The jump code is as follows:
Copy the code The code is as follows:
if (!($from >= 0 && $to <= 0))
header('Location: http://www.jb51.net/404. html');
else
header('Location: http://www.jb51.net/index.html');
?>
http://www.bkjia.com/PHPjc/321726.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321726.htmlTechArticleAssume there is an IP address range 192.168.0.0~192.168.0.255. The code that only allows access to this IP segment is as follows: Copy The code is as follows: ?php $IP = $_SERVER['REMOTE_ADDR']; $from = strcmp($IP,'...