473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Send out different content depends on User Agent String

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?

Thank you.

Jan 27 '06 #1
3 1827
Al************@gmail.com 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"}?>
Jan 27 '06 #2
NC
Al************@gmail.com wrote:

Is there an easy way in PHP which send outs different content
depends on User Agent String value?
Yes. There is a superglobal variable $_SERVER['HTTP_USER_AGENT']
If yes, is there an example/documentation?


Here is the documentation on the subject in its entirety:

'HTTP_USER_AGENT'
Contents of the User-Agent: header from the current request,
if there is one. This is a string denoting the user agent being
which is accessing the page. A typical example is: Mozilla/4.5
[en] (X11; U; Linux 2.2.9 i586). Among other things, you can
use this value with get_browser() to tailor your page's output
to the capabilities of the user agent.

Source:
http://www.php.net/manual/en/reserve...riables.server

Cheers,
NC

Jan 27 '06 #3
d

<Al************@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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?
Be aware that the user agent string can be changed, and therefor isn't as
accurate as detecting the browser using javascript (but, on the other hand,
is completely transparent)
Thank you.


dave
Jan 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
2
by: @rpus - Development | last post by:
I have the folloving function in vb .net: Function SendXMLReq() As String Dim returnval As String Dim xmlhttp As Object = New MSXML2.ServerXMLHTTP Dim objXMLSend = New MSXML2.DOMDocument Dim...
8
by: Lian | last post by:
Hi all, It is a newbie's question about html tag "img". The attributes "title" and "alt" for "img" seems having the same function. So what is the main difference between them? Can i use them at...
4
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I...
11
by: Jovo Mirkovic | last post by:
I have a simple Form with a Button1 and TextBox1. When I click button, I want execute a Sub procedure with name TextBox1.Text... Is it possible? Thanks, Jovo
1
by: mfreeman | last post by:
I have a VB.NET 2005 Windows application that worked fine when I ran it a month ago, and now it is throwing an exception ("The remote server returned an error: (500) Internal Server Error.") and I...
35
by: RobG | last post by:
Seems developers of mobile applications are pretty much devoted to UA sniffing: <URL: http://wurfl.sourceforge.net/vodafonerant/index.htm > -- Rob
2
by: anu b | last post by:
Now i am sending email to my friend using session variable... but my code is as below private bool SendEmail(string email) { try
1
by: deepaks85 | last post by:
Dear All, I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.