i-CONICA
asked on
How to do "less than" with this...?
Hi,
I'm using this code, but I need it to return true only if it's detected less than IE8...
Could someone help modify this to do this?
Thanks. :D
I'm using this code, but I need it to return true only if it's detected less than IE8...
Could someone help modify this to do this?
Thanks. :D
function detect_ie(){
if(isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.0') != false)){
return true;
}
else{
return false;
}
}
Yuck... I rushed that. Here is the correct code:
$explode_set1 = explode('(',$_SERVER['HTTP_USER_AGENT']);
$explode_set2 = explode(';',$explode_set1[1]);
foreach ($explode_set2 as $element) {
if (ereg("MSIE",$element)) {
$this_element = trim($this_element);
$this_element = explode(' ',$element);
if ($this_element[2] < "8") {
echo "true";
break;
} else {
echo "false";
break;
}
}
}
ASKER
I was thinking a more simple solution would be possible? :(
Like maybe a substr on MSI 8.0 to take it to character 5 which is the number 8, then compare to see if it's less than 8...
Would that be possible? Any implications in doing it that way? :S
Like maybe a substr on MSI 8.0 to take it to character 5 which is the number 8, then compare to see if it's less than 8...
Would that be possible? Any implications in doing it that way? :S
Have you tried using the get_browser function?
http://php.net/manual/en/function.get-browser.php
http://php.net/manual/en/function.get-browser.php
ASKER
Yeah, that'd be ideal, but it needs the browercap.ini file installed on the system and that's 300KB to load... a bit heavy to use for such a tiny feature... :(
Off the top of my head the above two solutions are all I can come up with.
I don't see how substr would work because the 'HTTP_USER_AGENT' variable would look different for every browser.
Guess you need to decide how important this feature is to you and whether you're willing to use a solution like the one provided above to accomplish it.
I don't see how substr would work because the 'HTTP_USER_AGENT' variable would look different for every browser.
Guess you need to decide how important this feature is to you and whether you're willing to use a solution like the one provided above to accomplish it.
ASKER
"I don't see how substr would work because the 'HTTP_USER_AGENT' variable would look different for every browser."
It's either going to be MSIE 6.0, MSIE 7.0, MSIE 8.0, I think... So I could use stristr to find the MSIE part, plus 4 characters, into a new string and then 5 characters in, would be the version number... Sounds flaky and fiddly I know.. I was hoping something along those lines could be done.. :(
It's either going to be MSIE 6.0, MSIE 7.0, MSIE 8.0, I think... So I could use stristr to find the MSIE part, plus 4 characters, into a new string and then 5 characters in, would be the version number... Sounds flaky and fiddly I know.. I was hoping something along those lines could be done.. :(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window