Home  >  Article  >  Backend Development  >  National examination common sense judgment php visiting domestic and foreign IP judgment code and realize page jump

National examination common sense judgment php visiting domestic and foreign IP judgment code and realize page jump

WBOY
WBOYOriginal
2016-07-29 08:41:311551browse

I roughly thought about it, and there are two options:
1. Javascript determines the browser language of the visitor. If it is a Chinese system, the users will naturally be Chinese and will jump to the Chinese website;
If it is a non-Chinese system, the default user will be non-Chinese. Chinese people, jump to English websites.
Advantages: Fast judgment and reflection.
Disadvantages: Inaccurate, it is possible that Chinese users prefer to use the English version of the system, or foreigners use the Chinese system.
Code

Copy code The code is as follows:




2. Use the IP library to judge the visiting IP
Advantages: Accurate judgment.
Disadvantages: The response speed is not as fast as Javascript.
You need to reference a PHP IP library ip_php.zip
I quoted jquery at the head of the website for judgment

Copy the code The code is as follows:




Copy code The code is as follows:


$userip=$_SERVER['REMOTE_ADDR'];
// To reference the files of the ip library, place all the files in ip.zip in the lib directory
include_once('/lib/iplimit.class.php');
$iplimit = new iplimit;
if($iplimit->setup( $userip))
{
echo 1;
}
else
{
echo 2;
}


Both methods can perfectly determine the visiting IP. Which one you choose depends on your specific needs.

The above introduces the national examination common sense judgment PHP to visit domestic and foreign IP judgment code and realize page jump, including the content of the national examination common sense judgment, I hope it will be helpful to friends who are interested in PHP tutorials.

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