title: PHP redirect based on HTTP_USER_AGENT
body: <p>I'm trying to redirect my page based on User Agent. I've written a piece of code and included it before <code>&lt;!doctype html&gt;</code> </p>
  
  <pre><code>$SAFARI_URL = "https://example.com/ms/";
  $OPERA_URL = "https://example.com/ms/";
  $OTHER_URL = "https://example.com/";
  $CHROME_URL = "https://example.com/";
  // Redirection code
  $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
  
  function str_present($str,$substr)
  {
    $pos = strpos($str,$substr);
  
    if($pos === false) {
     return false;
    }else {
      return true;
    }
  }
  
    if (str_present($HTTP_USER_AGENT, "Safari")){ 
      Header ("Location: " . $SAFARI_URL);
    }else if (str_present($HTTP_USER_AGENT, "Opera")){ 
      Header ("Location: " . $OPERA_URL);
    }else if (str_present($HTTP_USER_AGENT, "Chrome")){ 
      Header ("Location: " . $CHROME_URL);
    }else{ 
      Header ("Location: " . $OTHER_URL);
    }
  </code></pre>
  
  <p>The issue is that it's not working for Chrome. Am I doing something wrong? Is it not precise enough?</p>