title: PHP HTTP_User_Agent, redirecting visitors to the mobile page, site performance down
body: <p>We were working on a mobile version of our site.</p>
  
  <p>Some programmers put up this code on our normal non-mobile page.  The result was that our site started to perform very slowly and bug out.</p>
  
  <p>I'm thinking that the new mobile page may have had some bad code that was creating the issues, but I wanted to know if the code snippit put on our existing pages was problematic.</p>
  
  <p>Here is is:</p>
  
  <pre><code>&lt;?php
  $iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
  $android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
  $palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
  $berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
  $ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
  
  if ($iphone || $android || $palmpre || $ipod || $berry == true)
  {
  header('Location: http://m.site.com/index.php?id='.$HTTP_GET_VARS["id"]);
  //OR
  //echo "&lt;script&gt;window.location='http://mobile.site.com'&lt;/script&gt;";
  }
  </code></pre>
  
  <p>Someone from our hosting company suggested that the code maybe should have '===' instead of '==' at the end of the if statement.</p>
  
  <p>Does the code look problematic?</p>
  
  <p>Thanks as always.</p>