PHP Tutorials

XMLStyleSoldierFlowerMonkey

Browser-Dependent Stylesheets

Learn how to make a Browser-Dependent Stylesheets using PHP.

Spreadshirt
Simply copy the below code into the head of your PHP document. Remember, the page your working on must have a .php extension, and your server must be running PHP. Like in the above code, you need to specify the path of the two stylesheets. I've done so below in red.
<?
if ($name = strstr ($HTTP_USER_AGENT, "MSIE")) 
{ 
?>
<link rel="stylesheet" href="internet-explorer-stylesheet.css">
<?
} 
else if ($name = strstr ($HTTP_USER_AGENT, "Netscape")) 
{ 
?>
<link rel="stylesheet" href="netscape-stylesheet.css">
<?
} 
else
{ 
?>
<link rel="stylesheet" href="other-stylesheet.css">
<?
} 
?>
Quite simple wasn't it? If you have more questions, email us at webmaster@spoono.com or post on the discussion forum.

Discuss this tutorial »
Written by: Akash Goel
Back to PHP TutorialsTop


Copyright © 2000-2008 Spoono, LLC. All rights reserved.
Network: Reseller Web Hosting by Spoono Host | Spoonloads | Absolute Cross
Terms of Service | Privacy Policy.

kdfj