Hello all,
I was just thinking it would be easier (although it would take time) that i create different CSSs for different browsers and call these CSSs via PHP depending on the browser. Is this worth doing?
This is the current script i am using to detect different browsers. Making a call to this script a page loads everytime: is this efficient?
[PHP]<?php
$useragent = $_SERVER['HTTP_USER_AGEN T'];
if (preg_match("|M SIE ([0-9].[0-9]{1,2})|",$usera gent,$matched)) {
$browser_versio n=$matched[1];
$browser = "IE";
} else if (preg_match("|O pera ([0-9].[0-9]{1,2})|",$usera gent,$matched)) {
$browser_versio n=$matched[1];
$browser = ‘Opera’;
} else if(preg_match(" |Firefox/([0-9\.]+)|",$useragent ,$matched)) {
$browser_versio n=$matched[1];
$browser = "Firefox";
} else if(preg_match(" |Safari/([0-9\.]+)|",$useragent ,$matched)) {
$browser_versio n=$matched[1];
$browser = "Safari";
} else {
// browser not recognized!
$browser_versio n = 0;
$browser= "other";
}
print "browser: $browser";
?>[/PHP]
Is there anything else i can do to boost performance?
Thanks all, I appreciate any help. :)
I was just thinking it would be easier (although it would take time) that i create different CSSs for different browsers and call these CSSs via PHP depending on the browser. Is this worth doing?
This is the current script i am using to detect different browsers. Making a call to this script a page loads everytime: is this efficient?
[PHP]<?php
$useragent = $_SERVER['HTTP_USER_AGEN T'];
if (preg_match("|M SIE ([0-9].[0-9]{1,2})|",$usera gent,$matched)) {
$browser_versio n=$matched[1];
$browser = "IE";
} else if (preg_match("|O pera ([0-9].[0-9]{1,2})|",$usera gent,$matched)) {
$browser_versio n=$matched[1];
$browser = ‘Opera’;
} else if(preg_match(" |Firefox/([0-9\.]+)|",$useragent ,$matched)) {
$browser_versio n=$matched[1];
$browser = "Firefox";
} else if(preg_match(" |Safari/([0-9\.]+)|",$useragent ,$matched)) {
$browser_versio n=$matched[1];
$browser = "Safari";
} else {
// browser not recognized!
$browser_versio n = 0;
$browser= "other";
}
print "browser: $browser";
?>[/PHP]
Is there anything else i can do to boost performance?
Thanks all, I appreciate any help. :)
Comment