How to get the language value from $_SERVER['HTTP_ACCEPT_LANGUAGE'] using PHP?

后端 未结 4 1923
野性不改
野性不改 2020-12-08 11:19

When I use Firefox to test this block of code, I get en-us,en;

4条回答
  •  长情又很酷
    2020-12-08 12:14

    As of v5.3 PHP has function for that purpose:

    $locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
    

    See: http://php.net/manual/en/locale.acceptfromhttp.php

提交回复
热议问题