What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » formatting web browsers

formatting web browsers
Author: Message:
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. formatting web browsers
Ok,
Well i've been confused on how to format browsers so they display as Firefox or
IE6 using php. I've resorted to str_ireplace temporarily but i need to know if there's an eaiser way using arrays or whatever or if theres a function to do this with.

thanks guys,
Nathna
Touch Innovation - touch friendly programs/applications for the windows mobile!


05-08-2007 06:11 PM
Profile E-Mail PM Web Find Quote Report
Baggins
Full Member
***

Avatar
B000ALFAZO

Posts: 387
Reputation: 13
30 / Male / Flag
Joined: Oct 2006
RE: formatting web browsers
If you mean detect the browser type I would use RegExp on $_SERVER['HTTP_USER_AGENT']

[offtopic]
Nice to meet you Nathna:)
05-08-2007 07:05 PM
Profile E-Mail PM Web Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. RE: formatting web browsers
Could you give me an example please?

Cheers.
Touch Innovation - touch friendly programs/applications for the windows mobile!


05-08-2007 08:32 PM
Profile E-Mail PM Web Find Quote Report
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
RE: formatting web browsers
What are you trying to do Nath? Your post is very confusing :P
05-08-2007 08:33 PM
Profile PM Find Quote Report
user35870
Disabled Account


Posts: 858
Joined: Aug 2004
Status: Away
RE: formatting web browsers
I'm not sure if this is the best way to do it or is what you mean, but here go's:

code:
<?php
$browser = $_SERVER['HTTP_USER_AGENT'];

if (preg_match("/firefox/i", "$browser")) {
$result = "Mozilla Firefox";
}
elseif (preg_match("/ie/i", "$browser")) {
$result = "Internet Explorer";
}
elseif (preg_match("/opera/i", "$browser")) {
$result = "Opera";
}
else {
$result = "Unknown";
}
echo "<strong>$result</strong>";
?>


(note: I've only done some examples, you can expand it for others such as Netscape if you want.)

This post was edited on 05-08-2007 at 08:42 PM by user35870.
05-08-2007 08:33 PM
Profile PM Find Quote Report
Nathan
Veteran Member
*****

Avatar
Yeah, "large dimensions" ;)

Posts: 2984
Reputation: 76
– / Male / Flag
Joined: Apr 2005
O.P. RE: formatting web browsers
That's exactly what I want Chris <3

Thanks :)
Touch Innovation - touch friendly programs/applications for the windows mobile!


05-08-2007 08:34 PM
Profile E-Mail PM Web Find Quote Report
absorbation
Elite Member
*****

Avatar

Posts: 3636
Reputation: 81
– / Male / Flag
Joined: Feb 2005
RE: formatting web browsers
Here is a small script I use from Hmaster:

code:
if (preg_match("/Firefox/", $agent))
    {
        $agent = "Firefox";
    }
   
    elseif (preg_match("/Safari/", $agent))
    {
        $agent = "Safari";
    }
   
    elseif (preg_match("/Opera/", $agent))
    {
        $agent = "Opera";
    }
   
    elseif (preg_match("/Netscape/", $agent))
    {
        $agent = "Netscape";
    }
   
    elseif (preg_match("/Konqueror/", $agent))
    {
        $agent = "Konqueror";
    }
   
    elseif (preg_match("/Camino/", $agent))
    {
        $agent = "Camino";
    }
   
    elseif (preg_match("/MSIE/", $agent))
    {
        $agent = "Internet Explorer";
    }
   
    elseif (preg_match("/Mac/", $agent))
    {
        $agent = "Macintosh";
    }
   
    elseif (preg_match("/Mozilla/", $agent))
    {
        $agent = "Mozilla";
    }
   
    else
    {
        $agent = "Unknown Browser";
    }

$agent represents the variable of the user's browser. Add the value yourself ;).
05-08-2007 08:38 PM
Profile PM Find Quote Report
FineWolf
Full Member
***

Avatar
Space Artist

Posts: 188
Reputation: 12
– / Male / Flag
Joined: Sep 2003
RE: formatting web browsers
Or, if you need advanced browser detection:
http://apptools.com/phptools/browser/
[Image: spacesigkj4.png]
05-08-2007 10:19 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On