...

View Full Version : Php check browser



thesavior
10-31-2006, 01:17 AM
My code doesn't work and I'm not sure why. It is supposed to check whether someone is using IE. I'm trying to do this the fastest way possible, so help would be appreciated.


<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE") === TRUE)
{
echo "IE.";
}
else
{
echo "something better";
}
?>


This is always returning "something better" even if viewed in IE. Any ideas why?

CFMaBiSmAd
10-31-2006, 01:52 AM
strpos will return FALSE if it does not find a match or it will return an integer value which is the start of the first occurrence it finds. It will never return a match for === TRUE

thesavior
10-31-2006, 02:16 AM
so i just need to switch the order of everything. Okay

felgall
10-31-2006, 05:04 AM
Of course most browsers will claim to be IE so that crappy old scripts that test for what browser it is rather than what the browser needs to support will still work.

thesavior
10-31-2006, 05:49 AM
You can see the check in action here: http://dev.powerwd.com/AXClan/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum