I am working on a Laravel project and got an empty string the following code.
<?php
use Locale;
$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
// or $locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo $locale;
The result should be en-US
, but returns empty string. I could confirm the request header on my Google Chrome browser v95.
Accept-Language: en-US,en;q=0.9
How can I resolve this issue?
source https://stackoverflow.com/questions/69743272/localeacceptfromhttp-not-working-correctly
Comments
Post a Comment