title: php to detect browser
body: <p>Ive got an odd css fault that i cant seem to fix, its only occuring in safari, not chrome so webkit targeting wont help.. what i was trying to do is set a block of php to check if the browsers safari, if so echo a peice of css. </p>
  
  <p>So far ive got this (bellow) - Which works, but its also outputting the echo statement in chrome, any idea were ive gone wrong ? </p>
  
  <pre><code>&lt;?php 
  
      if(isset($_SERVER['HTTP_USER_AGENT'])){
           $agent = $_SERVER['HTTP_USER_AGENT'];
      }
  
      if(strlen(strstr($agent,"Safari")) &gt; 0 ){
          $browser = 'safari';
      }
      if($browser=='safari'){
          echo '&lt;style&gt;p {font-weight: 300;}&lt;/style&gt;';
      }
  
  ?&gt;
  </code></pre>
  
  <p>Ive just been playing arround with <code>echo $_SERVER["HTTP_USER_AGENT"];</code> and this is what i get from safari </p>
  
  <blockquote>
    <p>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.17
    (KHTML, like Gecko) Version/6.0.2 Safari/536.26.17</p>
  </blockquote>
  
  <p>and from chrome </p>
  
  <blockquote>
    <p>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22
    (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22</p>
  </blockquote>
  
  <p>So it can tell its different browsers, but its obviously reading them both as Apple Web Kit, rather than safari or chrome. My php is a bit rusty how would i get it to target the safari user agent specificly ? </p>