Re: decision between explorer types
| From: | Nicole Amashta | Date: | Wed, 27 Mar 2002 14:31:22 +0000 |
| Subject: | Re: decision between explorer types | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-12778@lists.php.net to get a copy of this message | ||
You need to try a broader check. You can use regular expressions for this:
if ( eregi( "ie", $HTTP_USER_AGENT ) ) ## IE browsers (all versions)
{
## do something
}
else ## all other browsers
{
## do something
}
The regular expression "eregi" is a case-insensitive search. You can use ereg for
case-sensitive search.
There is also the "perl" regular expression function: preg_match, where you use perl like
regular expressions. So,
the above code would look like this:
if ( preg_match( "/ie/i", $HTTP_USER_AGENT ) ) ## IE browsers (all versions)
{
## do something
}
else ## all other browsers
{
## do something
}
In this case, the regex "/ie/i" .. the 'i' aftere the last '/'
signifies a case-insensitive search.
Hope this helps! It works for me.
Good luck,
Nicole Amashta
www.aeontrek.com
"Fabian Hoffmann" <fhoffmann@communova.com> wrote in message news:20020327093110.55097.qmail@pb1.pair.com...
> Hi all!
>
> I need your for a buggi PHP-Skript!
>
> At the start of my Page my Script must automaticly decide between IE or
> other Explorers!! Because the Iex Version is another then the Netscape
> Version!!
>
> My Scipt at the moment:
>
> <?php
>
> if($HTTP_USER_AGENT=="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)")
>
> {?>
>
> <meta http-equiv="refresh"
> content="0;URL=deutsch/index.php?con=home.htm">
>
> <?}
>
> else
>
> {?>
>
> <meta http-equiv="refresh" content="0;URL=cnv/index.htm">
>
> <?}?>
>
> The Problem is I cant write all Iex versions into the script... or I wont
> ...
>
> Have anyone an idea ?????????????
>
>