Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 641423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:03:40+00:00 2026-05-13T21:03:40+00:00

<?php $language = $_SERVER[‘HTTP_ACCEPT_LANGUAGE’]; echo $language; ?> When I use Firefox to test this

  • 0
<?php
$language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
echo $language;
?>

When I use Firefox to test this block of code, I get en-us,en;q=0.7,ja;q=0.3,

when I use IE to test the block of code, I get zh-cn.

Is the value of $_SERVER['HTTP_ACCEPT_LANGUAGE'] a string? How to determine whether the preferred language is Chinese or Japanese? How can I write a regular expression to get the language from the value of $_SERVER['HTTP_ACCEPT_LANGUAGE']?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:03:40+00:00Added an answer on May 13, 2026 at 9:03 pm

    Yes, the value of $_SERVER['HTTP_ACCEPT_LANGUAGE'] is a string — see $_SERVER.

    Its content is sent by the browser — which explains why you get different results depending on the browser you are using : most likely, your Firefox is configured to request pages in english (high priority) or japanese (low priority), while your IE is configured to request pages in chinese.

    This is because that HTTP header can contain :

    • a list of languages
    • optionnaly, with region codes
    • with associated priorities.

    The idea being that the server should respond, using the language that suits “the best” what’s requested by the user.

    About parsing that header, this blog-post might be a interesting read : Parse Accept-Language to detect a user’s language

    There is a portion of code proposed to parse that HTTP header — and it generates an array that looks like this (quoting) :

    Array
    (
        [en-ca] => 1
        [en] => 0.8
        [en-us] => 0.6
        [de-de] => 0.4
        [de] => 0.2
    )
    

    Which is an array of languages, sorted by priority, in descending order — which is probably what you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PHP returns Accept-Languages ($_SERVER['HTTP_ACCEPT_LANGUAGE']) in a format like en-US, en, de-AT. How can I
I use the PHP language for file upload and want to know that the
Language: PHP / Using Class Upload by Colin Verot About: Multiple Uploading The code
I am having this Error in PHP: Language string failed to load: recipients_failed My
as you know we can get post field by server side language like php,for
i've been making web app's and working with various server side language like php,
I came from PHP language(codeigniter), but now I learning ASP.Net MVC :) In PHP
I have a function in PHP language to create an xml file when requested.
I've started to learn OO programming, but using the PHP language with the help
Language: PHP / MySQL I am going out of my mind, I really have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.