sirbrent
12-07-2007, 11:30 PM
errr, the subject was meant to be: Using PHP to import browser specific CSS
Hello, I am trying to write a PHP script that will import a specific css stylesheet depending on browser type.
it am using an old script i had which told you if your browser version was out of date, but im trying to modify it for this purpose.
here is a sample of the the page running the script
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php include("bcscript.php"); ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Browser Check Tester</title>
</head>
<body>
</body>
</html>
and the script code ("bcscript.php" in the above example) i am trying to modify is this:
<?php
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) {
echo "string for IE goes here";
} else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') ) {
echo "string for Safari goes here";
} else {
echo "string for all browsers except safari and ie goes here";
}
?>
so basically i want to load a specific css for ie and safari and then a default one for all other browsers. i know there are several ways to do this, but this is the method i want to use for my purpose.
so how can i insert something like this into the echo string for the PHP?
<link href="ieonly.css" rel="stylesheet" type="text/css" />
thanks for any help.
Hello, I am trying to write a PHP script that will import a specific css stylesheet depending on browser type.
it am using an old script i had which told you if your browser version was out of date, but im trying to modify it for this purpose.
here is a sample of the the page running the script
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php include("bcscript.php"); ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Browser Check Tester</title>
</head>
<body>
</body>
</html>
and the script code ("bcscript.php" in the above example) i am trying to modify is this:
<?php
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) {
echo "string for IE goes here";
} else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') ) {
echo "string for Safari goes here";
} else {
echo "string for all browsers except safari and ie goes here";
}
?>
so basically i want to load a specific css for ie and safari and then a default one for all other browsers. i know there are several ways to do this, but this is the method i want to use for my purpose.
so how can i insert something like this into the echo string for the PHP?
<link href="ieonly.css" rel="stylesheet" type="text/css" />
thanks for any help.