PHP implements jumping to different language page codes according to the browser_PHP tutorial

WBOY
Release: 2016-07-21 15:00:02
Original
970 people have browsed it

Copy code The code is as follows:

$lan = $_SERVER['HTTP_ACCEPT_LANGUAGE']; //Get Browser language version
if (preg_match("/[zh]{2}-[hk]{2}/", $lan) || preg_match("/[zh]{2}-[tw]{2 }/", $lan)) {//Taiwan and Hong Kong go to the traditional Chinese page
$url = 'hk/index.php';
header("location: " . $url);
} elseif (preg_match("/(?i)^[en]/", $lan)) { //English countries go to the English page
$url = 'en/index.php';
header("location : " . $url);
} elseif (preg_match("/[zh]{2}-[cn]{2}/", $lan)) { //Go to the simplified Chinese page in mainland China
$ url = 'cn/index.php';
header("location: " . $url);
} else { //Others go to English or other pages
$url = 'en/index. php';
header("location: " . $url);
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328090.htmlTechArticleCopy the code as follows: ?php $lan = $_SERVER['HTTP_ACCEPT_LANGUAGE']; //Get the browser language Version if (preg_match("/[zh]{2}-[hk]{2}/", $lan) || preg_match("/[zh]{2}-[tw]{2}/"...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!