Re: Send out different content depends on User Agent String
- From: "Sune Storgaard" <nospam@xxxxxxxxxxxxx>
- Date: Fri, 27 Jan 2006 07:13:48 +0100
Allerdyce.John@xxxxxxxxx wrote:
> Hi,
>
> Is there an easy way in PHP which send outs different content depends
> on User Agent String value?
> If yes, is there an example/documentation?
Im not sure what exactly you want to achieve, but this reserved variable
will contain the useragent string (which can be forged easely)
$_SERVER['HTTP_USER_AGENT']
It will return something like this:
"Mozilla/5.0 (Windows; U; Windows NT 5.1; da; rv:1.8) Gecko/20051111
Firefox/1.5"Use some str function to check for occurences of "mozilla" and
do some conditional code based on result ?A little untested
example:<?php$ouragent = $_SERVER['HTTP_USER_AGENT']; // could be fitted
into the IF sentence if (substr_count($ouragent,"Mozilla")!=0) {
echo "Mozilla..maybe";}else{ echo "some other stuff"}?>
.
- References:
- Send out different content depends on User Agent String
- From: Allerdyce . John
- Send out different content depends on User Agent String
- Prev by Date: Re: Auto-documenting existing code? (not just PhpDoc)
- Next by Date: Re: PHP-Yes, HTML-No --- Why?
- Previous by thread: Send out different content depends on User Agent String
- Next by thread: Re: Send out different content depends on User Agent String
- Index(es):
Relevant Pages
|