title: Detecting browser language in PHP and redirect
body: <p>I want to write a simple if statement using HTTP_ACCEPT_LANGUAGE function that redirects based on result of what the users browser language is. I am still a beginner so am obviously keeping it as simple as possible. This is what I have so far but the "if" statement needs work. Can anyone help me with a fix?</p>
  
  <pre><code>&lt;?php
  $lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  if ($lang=german) {
      header("Location: http://www.example.com/german/index.html");
      } else if ($lang=spanish) {
          header("Location: http://www.example.com/spanish/index.html");
          }
          else if ($lang=french) {
              header("Location: http://www.example.com/french/index.html");
              }
              else if ($lang=chinese) {
                  header("Location: http://www.example.com/chinese    /index.html");
                      } else {
                      echo "&lt;html&gt;english content&lt;/html&gt;";
                      }
  
  ?&gt;
  </code></pre>