I’m using $lang=$_SERVER['HTTP_ACCEPT_LANGUAGE']; to detect the language of the browser. At first, I thought something was wrong with my code. But then I tried this demo, and even if I had my ‘display preferred language’ as Spanish (es), it displayed the content in English (en). Finally, I figured out that it doesn’t work in localhost (Using WAMP server 2), but it does online.
What is the reason?
If the browser doesn’t send an
Accept-Language:request header, the PHP default isen.Fix for Firefox: Type
about:configin the address bar. Then change the following entries: