首页 | 注册 | 登录 | 归档 | 搜索 | 标签 | 在线工具

php实现识别系统首选语言跳转

php实现识别系统首选语言跳转
类似google

<?php
error_reporting
(E_ALL E_NOTICE);
// 分析 HTTP_ACCEPT_LANGUAGE 的属性
// 这里只取第一语言设置 (其他可根据需要增强功能,这里只做简单的方法演示)
preg_match('/^([a-z\-]+)/i'$_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches);
$lang $matches[1];
switch (
$lang) {
                     case 
'zh-cn' :
                                         
header('Location: http://cn.test.com/');
                                         break;
                     case 
'zh-tw' :
                                         
header('Location: http://tw.test.com/');
                                         break;
                     case 
'ko' :
                                         
header('Location: http://ko.test.com/');
                                         break;
                     default:
                                         
header('Location: http://en.test.com/');
                                         break;
}
?>

Tags: 代码收藏, php

Address: http://www.amxku.net/archives/605/

上一篇 »» MSSQL安全设置
下一篇 »» PHP各种Template系统

相关文章

发表评论

评论内容: