User-friendly language information on _SERVER [HTTP_ACCEPT_LANGUAGE] Variable information is similar to this "zh-cn", if it is multi-language column, is similar to "zh-cn, en; q = 0.8, ko; q = 0.5, zh-tw; q = 0.3" The following questions can be solved. Code:
<? php error_reporting (E_ALL ^ E_NOTICE); // Analyze the properties of HTTP_ACCEPT_LANGUAGE // Here only take the first language settings (others can be enhanced as needed, here only a simple method to demonstrate) preg_match (/ ^ ([az -] +) / i, _SERVER [HTTP_ACCEPT_LANGUAGE], matches); lang = matches [1]; switch (lang) { case zh-cn: header (Location: http://cn.example.com/); break; case zh-tw: header (Location: http://tw.example.com/); break; case ko: header (Location: http://ko.example.com/); break; default: header (Location: http://en.example.com/); break; } ?>
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.