Function that changes the language of my site based on http_accept_language


My website is displayable in 2 languages, English and dutch, and I want to show the dutch language if the http_accept_language is present and set to dutch [nl-NL?], the attached code is my first attempt to do so, can someone improve this pls, it should display English in every other case if the http_accept_language is not set to dutch, or, do you know a better way to do this in php?
function ChangeLang(){
$Dutch = 'nl';
$Nl = 'lang/dutch.lang';
$En = 'lang/english.lang';
  if (strstr($_SERVER['HTTP_ACCEPT_LANGUAGE'],$Dutch)){
     else {

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
That code looks fine to me.  This is what my server presents:

_ENV["HTTP_ACCEPT_LANGUAGE"] = en-us,en;q=0.5

Be aware of variable scope since you are including these lang modules inside a function.

Best regards, ~Ray

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PeterdeBAuthor Commented:
Ok thank you very much, I already had taken notice of the variable scope but thanks again
Ray PaseurCommented:
Thanks for the points, and good luck with your project! ~Ray
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.