I’m setting up a check for IE in a wordpress theme I am developing. I wanted to check for Internet Explorer 7. So if I use the following code:
<?php
if (preg_match('/\bmsie 7/i', $ua) && !preg_match('/\bopera/i', $ua))
echo 'Do Something'
?>
Instead of:
<!--[if lt IE 7]>
Do Something
<![endif]-->
Is there any drawbacks to it? Just trying to load HTML only when it is needed. Any insight is appreciated.
EDIT
Found this really good article on doing it the PHP way: http://www.kingofdevelopers.com/php-classes/get-browser-name-version.php
Try detect the platform, the engine and the version, that cover a lot of possible browsers and let me code based on that, for example, the engine gecko, covers firefox, seamonkey and all the gecko based browsers.
in php use the