p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: What browser?


Message #1 by "Jon Shoreman" <jon.shoreman@b...> on Tue, 19 Feb 2002 20:37:02
I cannot get the function get_browser() to work !!



So I am trying another method.



If I echo $HTTP_USER_AGENT I get the following values:



When Using Netscape 4.79 = Mozilla/4.79 [en] (Win98; U)

When Using Netscape 6.2 = Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) 

Gecko/20011128 Netscape6/6.2.1

When Usining MSIE 6 = Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; yie6-

uk)



I need to know when the browser is Netscape version 4. How do I do this ??

It seems to me that the string "Mozilla/4.79 [en] (Win98; U)" doesn't tell 

me that the browser is netscape.

Message #2 by "Krister" <krister@m...> on Tue, 19 Feb 2002 22:49:55 +0100
Hi Jon



Try this:



if ( ! strstr ( $HTTP_USER_AGENT, "MSIE" ) )

 if ( strstr ( $HTTP_USER_AGENT, "Mozilla/4" ) ) {

 echo "Netscape 4";

 } else {

 echo "Not Netscape 4";

 }



Krister



----- Original Message -----

From: "Jon Shoreman" <jon.shoreman@b...>

To: "beginning php" <beginning_php@p...>

Sent: Tuesday, February 19, 2002 8:37 PM

Subject: [beginning_php] What browser?





> I cannot get the function get_browser() to work !!

>

> So I am trying another method.

>

> If I echo $HTTP_USER_AGENT I get the following values:

>

> When Using Netscape 4.79 = Mozilla/4.79 [en] (Win98; U)

> When Using Netscape 6.2 = Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4)

> Gecko/20011128 Netscape6/6.2.1

> When Usining MSIE 6 = Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; yie6-

> uk)

>

> I need to know when the browser is Netscape version 4. How do I do this ??

> It seems to me that the string "Mozilla/4.79 [en] (Win98; U)" doesn't tell

> me that the browser is netscape.

>




$subst('Email.Unsub').

>



Message #3 by "Lawrence" <lkrubner@g...> on Tue, 19 Feb 2002 17:07:56 -0500
You could check to make sure the string doesn't contain "MSIE" 





----- Original Message ----- 

From: "Jon Shoreman" <jon.shoreman@b...>

To: "beginning php" <beginning_php@p...>

Sent: Tuesday, February 19, 2002 8:37 PM

Subject: [beginning_php] What browser?





> I cannot get the function get_browser() to work !!

> 

> So I am trying another method.

> 

> If I echo $HTTP_USER_AGENT I get the following values:

> 

> When Using Netscape 4.79 = Mozilla/4.79 [en] (Win98; U)

> When Using Netscape 6.2 = Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) 

> Gecko/20011128 Netscape6/6.2.1

> When Usining MSIE 6 = Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; yie6-

> uk)

> 

> I need to know when the browser is Netscape version 4. How do I do this ??

> It seems to me that the string "Mozilla/4.79 [en] (Win98; U)" doesn't tell 

> me that the browser is netscape.

> 









  Return to Index