The code below can be used to add custom code based on the browser type. Load the page within the popular browsers like Firefox, Chrome, Explorer, Safari and Opera and you will see specific output for each one. The codes can be handy if you need to make a minor css adjustment, redirect, etc.
<?php ## CHROME if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false){ echo "This output will only display if the browser is Google Chrome"; } echo "<br/>"; if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') != false){ echo "This output will only display if the browser is Google Chrome"; } echo "<br/>"; if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') == true){ echo "This output will only display if the browser is Google Chrome"; } ## FIREFOX if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false){ echo "This output will only display if the browser is Firefox"; } echo "<br/>"; if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') != false){ echo "This output will only display if the browser is Firefox"; } echo "<br/>"; if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') == true){ echo "This output will only display if the browser is Firefox"; } ## EXPLORER if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false){ echo "This output will only display if the browser is Explorer"; } echo "<br/>"; if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') != false){ echo "This output will only display if the browser is Explorer"; } echo "<br/>"; if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') == true){ echo "This output will only display if the browser is Explorer"; } ## SAFARI if (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') == false){ echo "This output will only display if the browser is Safari"; } echo "<br/>"; if (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') != false && strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') == false){ echo "This output will only display if the browser is Safari"; } echo "<br/>"; if (strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') == true && strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') == false){ echo "This output will only display if the browser is Safari"; } ## OPERA if (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false){ echo "This output will only display if the browser is Opera"; } ?>
© 2018 ALL Rights Reserved | Sitemap
Vancouver | North Vancouver | Burnaby | Richmond | Coquitlam | Port Coquitlam | Surrey | Langley | Maple Ridge | Mission | Abbotsford | Kamloops | Kelowna | Victoria | Squamish | Whistler | Pemberton