National Test common sense PHP visit domestic and foreign IP Judgment Code and achieve page jump

Source: Internet
Author: User
I've probably conceived it, and there are two options:
1. JavaScript to determine the browser language of the visitors, if the Chinese system, natural users are Chinese, jump Chinese website;
If the non-Chinese system, the default user is not Chinese, jump English website.
Advantages: The judgment reflects the speed quickly.
Cons: Inaccurate, it is possible that Chinese users prefer to use the English version of the system, or foreigners using the Chinese system situation.
Code

Copy the Code code as follows:




2. Use IP library to make the judgment of visiting IP
Advantages: Accurate judgment.
Cons: The response speed is no JavaScript fast.
Need to reference a PHP IP library ip_php.zip
I'm referring to jquery on the head of the website to judge

Copy the Code code as follows:




Copy the Code code as follows:


$userip =$_server[' remote_addr '];
Files referencing IP libraries put all the files in the 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 be perfect to determine the visiting IP, choose which depends on your specific needs.

The above introduces the national test Common sense PHP to visit domestic and foreign IP Judgment Code and to achieve page jump, including the national test of common sense of the content, I hope that the PHP tutorial interested friends have helped.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.