php methods to prohibit IP access: 1. Use the "<?php include("banIP.php");?> method to prohibit access to a certain IP or IP address range; 2. Disable it through the die method A single IP is enough.
The operating environment of this tutorial: Windows 7 system, PHP version 5.6. This method is suitable for all brands of computers.
Recommended: "PHP Video Tutorial"
php method to prohibit access to a certain ip or ip address range
<?php include("banIP.php");?>
Disable a single ip as follows:
<?php //禁用ip地址 $ip=$_SERVER["REMOTE_ADDR"]; $ban=file_get_contents("ban.dat"); if(stripos($ban,$ip)) { die("Your IP Address is:$ip,you're forbiden to view this page!"); } echo "Your IP Address is:$ip,hello!"; ?>
The above is the detailed content of How to ban ip access in php. For more information, please follow other related articles on the PHP Chinese website!