" method to prohibit access to a certain IP or IP address range; 2. Use the die method to disable a single IP."/> " method to prohibit access to a certain IP or IP address range; 2. Use the die method to disable a single IP.">

Home  >  Article  >  Backend Development  >  How to ban ip access in php

How to ban ip access in php

藏色散人
藏色散人Original
2020-11-19 09:36:432973browse

php methods to prohibit IP access: 1. Use the "5be4021861fabab0144d5afdde295188 method to prohibit access to a certain IP or IP address range; 2. Disable it through the die method A single IP is enough.

How to ban ip access in php

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&#39;re forbiden to view this page!");   
} 
echo "Your IP Address is:$ip,hello!"; 
?>
rrree

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!

Statement:
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