html - how to know the browser using php code -
this question has answer here:
- reliable user browser detection php 8 answers
i have site uses textfields. in firefox, use css. when open site in google chrome, got different design of site.
i think solution having diferent css file different browser. need know browser used following users. change link css.. example:
<link href='site_css/firefox.css' rel='stylesheet' type='text/css' />
then if user uses google chrome,
<link href='site_css/firefox.css' rel='stylesheet' type='text/css' />
<?php // check browser visitor using $user_agent = $_server['http_user_agent']; // bit differentiates ie opera if(preg_match('/msie/i',$u_agent) && !preg_match('/opera/i',$u_agent)) { print 'this internet explorer. (insert joke here)'; } elseif(preg_match('/mozilla/i',$u_agent) && !preg_match('/compatible/', $useragent)) { print 'this firefox.'; } // let chrome recognized safari elseif(preg_match('/webkit/i',$u_agent)) { print 'this either chrome or safari.'; } elseif(preg_match('/opera/i',$u_agent)) { print 'this opera. live on edge, huh?'; } elseif(preg_match('/netscape/i',$u_agent)) { print 'this netscape, , need upgrade.'; } ?>
Comments
Post a Comment