Serving Northern Oakland and Macomb Counties.    Call to learn more: (586) 258-8627

If this browser show this code

« Go back

Different Code for Different Browsers

PHP

<?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) { ?>
	<!-- Your HTML goes Here -->
	<h1>You are using Firefox</h1>
<?php } ?>

<?php 
// Safari or Chrome. Both use the same engine - webkit
if ($safari || $chrome) { ?>
	<!-- Your HTML goes Here -->
	<h1>You are using a webkit powered browser</h1>
<?php } ?>

<?php
// IE
if ($msie) { ?>
	<!-- Your HTML goes Here -->
	<h1>You are using IE</h1>
<?php } ?>

<?php
// Not IE and for all other browsers
if (!$msie) { ?>
	<!-- Your HTML goes Here -->
	<h1>You are not using IE</h1>
<?php } ?>

Tags: ,