Hiya guys, I have a problem. I'm helping my bf manage his site. He has made all of his web pages .php instead of .html in order to call php headers and footers and use them for all pages. The problem is that it looks different in some of the browsers. To correct it, I found this .php script for changing stylesheets that looks simple, and it works in most cases except for ours. He has a .php main page, then the main page calls the php header and footer. Inside the header file, I am attempting call .css files using PHP, and here is the code.
<?php
//detect browser and send style sheet for that browser
if (strstr ($_SERVER[ 'HTTP_USER_AGENT'], "MSIE"))
{ echo "<link rel='stylesheet' href='ie.css'>"; }
else if (strstr ($_SERVER['HTTP_USER_AGENT'], "Netscape"))
{ echo "<link rel='stylesheet' href='net.css'>"; }
else if (strstr ($_SERVER['HTTP_USER_AGENT'], "Firefox"))
{ echo "<link rel='stylesheet' href='moz.css'>" ; }
else if (strstr ($_SERVER['HTTP_USER_AGENT'], "Opera"))
{ echo "<link rel='stylesheet' href='opera.css'>" ; }
else { echo "<link rel='stylesheet' href='other.css'>"; }
?>
The only problem is, this code does not like to be called using a php include... but if I pasted it within the main body it works, but I dont want to have to paste this code in every single body because it is messy. Any ideas?
P.S. : I researched other methods, such as Java Script(looks messy and complicated), Conditional Comments(works only in IE), and CSS hacking, and I do think this code is the easiest way. This is what I want to achieve ultimately:
I want to be able to edit the looks in Opera, IE, FF, Avant and Safari.
I dont really care about earlier versions of browsers that much
<?php
//detect browser and send style sheet for that browser
if (strstr ($_SERVER[ 'HTTP_USER_AGENT'], "MSIE"))
{ echo "<link rel='stylesheet' href='ie.css'>"; }
else if (strstr ($_SERVER['HTTP_USER_AGENT'], "Netscape"))
{ echo "<link rel='stylesheet' href='net.css'>"; }
else if (strstr ($_SERVER['HTTP_USER_AGENT'], "Firefox"))
{ echo "<link rel='stylesheet' href='moz.css'>" ; }
else if (strstr ($_SERVER['HTTP_USER_AGENT'], "Opera"))
{ echo "<link rel='stylesheet' href='opera.css'>" ; }
else { echo "<link rel='stylesheet' href='other.css'>"; }
?>
The only problem is, this code does not like to be called using a php include... but if I pasted it within the main body it works, but I dont want to have to paste this code in every single body because it is messy. Any ideas?
P.S. : I researched other methods, such as Java Script(looks messy and complicated), Conditional Comments(works only in IE), and CSS hacking, and I do think this code is the easiest way. This is what I want to achieve ultimately:
I want to be able to edit the looks in Opera, IE, FF, Avant and Safari.
I dont really care about earlier versions of browsers that much
Last edited: