Last updated on January 24th, 2022 at 10:12 am

In this tutorial we are having a script that can detect browser language and redirect user to a page which is configured for that specific language/location. If you have a multi language website this script will come handy since you can detect the language of the browser a user is using and determine using which language you should display your webpage for that user.

$language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
echo "The browser language is ".$language;

We are getting this information from the header send by the browser. You can also use this information to redirect a webpage accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *