<?php

// 分析 HTTP_ACCEPT_LANGUAGE 的属性   
// 这里只取第一语言设置 (其他可根据需要增强功能,这里只做简单的方法演示)   
preg_match('/^([a-z\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches);

// 全部转换为小写   
$lang = strtolower($matches[1]);  

echo $lang."<br>";

switch ($lang) {   
    case 'zh-cn' :   
        // header('Location: http://cn.example.com/');  
        echo "aa"; 
        break;   
    case 'zh-tw' :   
        // header('Location: http://tw.example.com/');  
        echo "bb"; 
        break;   
    default:   
        // header('Location: http://en.example.com/');   
        echo "cc";
        break;   
}

 

相关文章:

  • 2022-12-23
  • 2021-10-16
  • 2021-11-23
  • 2021-05-12
  • 2021-09-27
  • 2022-01-20
  • 2022-01-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2022-03-06
相关资源
相似解决方案