1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<?php $msie = strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE') ? true : false; $firefox = strpos($_SERVER["HTTP_USER_AGENT"], 'Firefox') ? true : false; $safari = strpos($_SERVER["HTTP_USER_AGENT"], 'Safari') ? true : false; $chrome = strpos($_SERVER["HTTP_USER_AGENT"], 'Chrome') ? true : false; ?> <?php //Firefox if ($firefox) { echo 'Firefox!'; echo '<style type="text/css">'; echo '.mydiv {margin-top: 380px;}'; echo '</style>'; } // Safari or Chrome. Both use the same engine - webkit if ($safari || $chrome) { echo 'Chrome / Safari'; echo '<style type="text/css">'; echo '.mydiv {margin-top: 80px;}'; echo '</style>'; } // IE if ($msie) { echo '<style type="text/css">'; echo '.mydiv {margin-top: 180px;}'; echo '</style>'; } ?> <div class="mydiv">Hello</div> |
and some others
[‘HTTP_USER_AGENT’], ‘Opera Mini’)
echo “Opera Mini”;
[‘HTTP_USER_AGENT’], ‘Opera’)
echo “Opera”;
[‘HTTP_USER_AGENT’], ‘Safari’)
echo “Safari”;