473,387 Members | 1,455 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,387 software developers and data experts.

How to detect the client computer is using PC Browser / Mobile Browser?

Thanks
Jun 2 '08 #1
8 6509
NC
On May 13, 8:01 pm, "George" <@wrote:
>
How to detect the client computer is using PC Browser / Mobile
Browser?
By analyzing the content of $_SERVER["HTTP_USER_AGENT"], which,
needless to say, can be missing or configured to say anything...

Cheers,
NC

Jun 2 '08 #2
On May 14, 4:01 am, "George" <@wrote:
Thanks
You could try looking at the user agent string and analysing that to
try and guess the browser, but in all honesty there's no 100% reliable
way to determine what browser the user is using. The user agent
string is sent by the browser but there's nothing preventing the
browser sending one that identifies it as a different browser from
what it actually is.

Why do you need to know what browser the user is using though? The
browser the user has should be irrelevant to what content they get
served. If you're attempting to get around browser rendering issues
(ie IE6 and its brain damaged CSS), then conditional comments in the
HTML is a better approach. Only IE recognises them, other browsers
ignore them, so you can use them to load IE specific stylesheets and
javascript to work around that browser's flaws.

Don't try using user agent analysis to lock certain browsers out of
your site! You're annoying users and driving them away, and those
determined enough and knowledgeable enough to spoof the user agent
string can get around any blocks you might put up any way.
Jun 2 '08 #3
On May 14, 6:01 am, "George" <@wrote:
Thanks
Hi,

You can see
http://techpatterns.com/downloads/ph..._detection.php

and

http://www.hostpc.com/community/showthread.php?t=1599

also

Think about this code and enjoy :)

<?php
//If principal is using a Palm, then set it for presentation changes,
etc.

$string = $_SERVER['HTTP_USER_AGENT'];
$substring = 'Palm';
$pos = 0;
$pos = strpos($string, $substring, $pos);
if ($pos =='')
{
$isPalm="0";
}
else {
$isPalm="1";
}
?>

Jun 2 '08 #4
On 14 May, 09:16, Gordon <gordon.mc...@ntlworld.comwrote:
Why do you need to know what browser the user is using though? The
browser the user has should be irrelevant to what content they get
served.
I think that the answer to this question is in the OP's original
question.

As with the mobile Google search page and lots of other pages, web
site designers recognise that viewing a page on a tiny mobile device's
screen is a very different experience to viewing it on a "standard"
computer monitor, quite apart from the connection speed differences
that are still commonly encountered between the 2 platforms.

I for one am very pleased that designers take this into account.

Do you build all your sites to look great on a 2.8inch screen and then
have vast areas of nothing on a PC monitor?
Jun 2 '08 #5
PHP-Arabia a écrit :
Think about this code and enjoy :)

<?php
//If principal is using a Palm, then set it for presentation changes,
etc.

$string = $_SERVER['HTTP_USER_AGENT'];
$substring = 'Palm';
$pos = 0;
$pos = strpos($string, $substring, $pos);
if ($pos =='')
{
$isPalm="0";
}
else {
$isPalm="1";
}
?>
<?php
$isPalm = (strpos($_SERVER['HTTP_USER_AGENT'], 'Palm') !== false);
?>

$isPalm is false/true.
--
Guillaume
Jun 2 '08 #6
On May 14, 12:47 pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 14 May, 09:16, Gordon <gordon.mc...@ntlworld.comwrote:Why do you need to know what browser the user is using though? The
browser the user has should be irrelevant to what content they get
served.

I think that the answer to this question is in the OP's original
question.

As with the mobile Google search page and lots of other pages, web
site designers recognise that viewing a page on a tiny mobile device's
screen is a very different experience to viewing it on a "standard"
computer monitor, quite apart from the connection speed differences
that are still commonly encountered between the 2 platforms.

I for one am very pleased that designers take this into account.

Do you build all your sites to look great on a 2.8inch screen and then
have vast areas of nothing on a PC monitor?
Could that not be accomplished with a stylesheet for mobile users
though? On reflection I can see that sending a mobile browser less
content is obviously a good thing given that they tend to have limited
bandwidth, but with clever site design the stylesheet should be able
to accomplish that.

I didn't fully appreciate the OP's question as he'd posted it into the
title and left his body more or less blank.
Jun 2 '08 #7
George escribió:
Thanks
You're welcome.

Oh, come on, don't write the whole question in the subject xD

Have a look at get_browser():

http://php.net/function.get_browser
http://browsers.garykeith.com/downloads.asp

You'll probably need to download the browser database
(lite_php_browscap.ini should be okay) but it's far more accurate that
any home made browser sniffing of your own. Just fetch the
"isMobileDevice" property and let others do the research.

--
-- http://alvaro.es - Ãlvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño MarÃ*a: http://www.demogracia.com
--
Jun 2 '08 #8
On 14 May, 15:37, Gordon <gordon.mc...@ntlworld.comwrote:
On May 14, 12:47 pm, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 14 May, 09:16, Gordon <gordon.mc...@ntlworld.comwrote:Why do you need to know what browser the user is using though? The
browser the user has should be irrelevant to what content they get
served.
I think that the answer to this question is in the OP's original
question.
As with the mobile Google search page and lots of other pages, web
site designers recognise that viewing a page on a tiny mobile device's
screen is a very different experience to viewing it on a "standard"
computer monitor, quite apart from the connection speed differences
that are still commonly encountered between the 2 platforms.
I for one am very pleased that designers take this into account.
Do you build all your sites to look great on a 2.8inch screen and then
have vast areas of nothing on a PC monitor?

Could that not be accomplished with a stylesheet for mobile users
though? On reflection I can see that sending a mobile browser less
content is obviously a good thing given that they tend to have limited
bandwidth, but with clever site design the stylesheet should be able
to accomplish that.
I don't see how the stylesheet could limit the amount of content being
sent.
Jun 2 '08 #9

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

Similar topics

1
by: ripken95 | last post by:
I connect to the internet through ADSL. I want to write the web page which can detect the connection status with javascript. This detection is like the signal detection in the mobile phone. If the...
2
by: Joe Abou Jaoude | last post by:
hi, in my web app, I need to detect if a client computer is a Mac. i thought to use Request.Browser.Platform, however i don't have a Mac to test on it, so i have no idea what I'll get in result....
1
by: onewebclick | last post by:
Is there a way to detect a browser cache is full using javascript or HTML thorugh a web page and inform the user to clear the cache to improve performance of the website. It looks like google's...
3
by: Sara | last post by:
HI, I want to code a program to detect GSM mobile (any kind) which connected through serial port to computer and then be able to send SMS through this mobile phone to other mobile phones, could...
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
4
by: Sara | last post by:
Hi I want to code a program which could send SMS through web page to mobile phone, but because there is no Service here such as SMPP , therefore I have GSM mobile phone which connected directly to...
11
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I have an aplication web asp.net 2.0 and I am Trying to detect the close event in browser, which is the best performance for do this ? What's up with Alt+F4, Refresh, user clicks X,...
22
by: Dan Rumney | last post by:
Hi all, I've been writing Javascript for quite a while now and have, of late, been writing quite a lot of AJAX and AJAX-related code. In the main, my dynamically generated pages are created...
1
by: s3raph | last post by:
Hi, I'm having trouble detecting the client machine connection lost when the client physically pushes the power or restart button on their computer. Using the code from Plater in the following...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.