Re: Is there a way to determine wich browser a visitor uses in php?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



----Dirty Code----

if((ereg("Nav", getenv("HTTP_USER_AGENT"))) || (ereg("Gold",
getenv("HTTP_USER_AGENT"))) || (ereg("X11",
getenv("HTTP_USER_AGENT"))) || (ereg("Mozilla", getenv(
"HTTP_USER_AGENT"))) || (ereg("Netscape", getenv("HTTP_USER_AGENT")))
AND (!ereg("MSIE", getenv("HTTP_USER_AGENT")))) $c_browser =
"Netscape";
elseif(ereg("MSIE", getenv("HTTP_USER_AGENT"))) $c_browser = "MSIE";
elseif(ereg("Lynx", getenv("HTTP_USER_AGENT"))) $c_browser = "Lynx";
elseif(ereg("Opera", getenv("HTTP_USER_AGENT"))) $c_browser = "Opera";
elseif(ereg("WebTV", getenv("HTTP_USER_AGENT"))) $c_browser = "WebTV";
elseif(ereg("Konqueror", getenv("HTTP_USER_AGENT"))) $c_browser = "Konqueror";
elseif((eregi("bot", getenv("HTTP_USER_AGENT"))) || (ereg("Google",
getenv("HTTP_USER_AGENT"))) || (ereg("Slurp",
getenv("HTTP_USER_AGENT"))) || (ereg("Scooter",
getenv("HTTP_USER_AGENT"))) || (eregi("Spider",
getenv("HTTP_USER_AGENT"))) || (eregi("Infoseek",
getenv("HTTP_USER_AGENT")))) $c_browser = "Bot";
else $c_browser = "Other";


On 11/23/05, Frank Armitage <frank.armitage@xxxxxxxxxxxxx> wrote:
> twistednetadmin wrote:
> > Thanks guys. That helps alot!
> >
> > But this:
> > <?php
> > print $_SERVER['HTTP_USER_AGENT'];
> > ?>
> >
> > Returned this using Mozilla: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
> > rv:1.7.12) Gecko/20050915 Firefox/1.0.7
> > And this using IE: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
> >
> > Does that just mean that it's not completely accurate?
> >
>
> Try get_browser()
> http://php.net/manual/en/function.get-browser.php
>
> HTH
> Frank
>
> --
> tradeOver | http://www.tradeover.net
> ....ready to become the King of the World?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
"In theory there is no difference between theory and practice.
In practice there is." -- Fortune Cookie

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux