Another PHP Script
Seeing as how the internet, for once, did not have the answers i needed, i wrote this little PHP Script...
If you need it, use it.. It'll help u a lot.. Cheers.
It's a ServerSide browser detection and info script... It's in php..
//assigns the HTTP_USER_AGENT Server Variable to a variable that we can access...
$HTTP_USER_AGENT_VARTHATWECANUSE = $_SERVER['HTTP_USER_AGENT'];
//displays all the info about the browser...
echo "$HTTP_USER_AGENT_VARTHATWECANUSE \n";
/*
Every browser, within the whole line of info about the browser, has a unique string that no other browser has....
eg...
For IE6:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; FDM)
For Firefox 1.07:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7
Do u notice that there is a unique string between those lines of browser info?
For firefox, the unique string is Firefox (Case sensitive) and for IE it's MSIE(Case Sensitive)
From there, you can determine the browser by checking if such a string(Firefox or MSIE) exists within the line of browser info..
*/
//the following checks if a string(in this case, Firefox), exists within a variable($HTTP_USER_AGENT_VARTHATWECANUSE). If it does, it returns the character within the specified variable where the desired string starts at, which in lay man's terms means, IF THE STRING EXISTS, A NON FALSE VALUE IS RETURNED. If it does not exist, it will return a boolean value of FALSE. And if it does not exist, you can tell that that wasn't the browser you want.
if(!strpos($HTTP_USER_AGENT_VARTHATWECANUSE, "Firefox"))
DO NON FIREFOX STUFF HERE
else
DO EVERYTHING ELSE HERE
/*If you want, you can also do a strpos on the browser version number. Or, if you want you also be more specific and search for exact strings like Firefox/1.0.7 or MSIE 6.0
KUDOS to fusionate.blogspot.com's owner for this one... :p
*/
//If you need more help, don hesitate to ask me..
//Cheers
No comments:
Post a Comment