preg_match(‘/^([a-z\-]+)/i‘, $_SERVER[‘HTTP_ACCEPT_LANGUAGE‘], $matches); $lang = $matches[1]; switch ($lang) { case ‘zh-cn‘ : //header(‘Location: http://cn.test.com/‘); echo "中国"; break; case ‘zh-tw‘ : // header(‘Location: http://tw.test.com/‘); echo "台湾"; break; case ‘ko‘ : //header(‘Location: http://ko.test.com/‘); break; default: // header(‘Location: http://en.test.com/‘); echo "英文"; break; }
时间: 2024-10-05 06:28:24