Mobile/Cell Phone Question?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Mobile/Cell Phone Question?

Post by Dale »

Just a small question really... is there a way to determine if a user is viewing a page on there mobile/cell phone?? Like would the php tag that determines your browser be different?? Because I'm thinking about making some kind of IF statement for my website. Eg;

Code: Select all

<?php
if($browser_tag == "Mozilla/IE *whatever*") {
$images = "enabled";
} else {
// In mobile view
$images = "disabled";
}
?>
What would the result of that tag that returns the users browser most likely to be if they're viewing on a phone??
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

The new phones - 3G ones - have xHMLT browser with thosands of colours, and good screen resolution - though not like the PC but most pages can be viewed in full. Its the internet connection thats expensive as its slow and therefore people tend to use WAP ot xHTML over WAP - inspite of having a device that can do a lot of multimedia.
If you tend to create a separate site for WAP / low-res based devices, you can have a separate link to it like wap.yourdomain.com or whatever.
Its difficult to check for a mobile-based browser as most have their own. Opera mobile is common though. You might want to check out Nokia Browsing Tools.
I guess the faster way out is to check if its not PC-based IE, FF, Netscape, etc - and then do an else for non PC based browsers.

Do post if you get a solution.
Dale
Forum Contributor
Posts: 466
Joined: Fri Jun 21, 2002 5:57 pm
Location: Atherstone, Warks

Post by Dale »

Cheers for the link, and yes I may take your advice and check for the "normal" online browsers. Because loading my site on a mobile phone could cost people loads! Due to the images.
darryladie
Forum Commoner
Posts: 62
Joined: Thu Mar 02, 2006 6:14 pm
Location: East Sussex, UK

Post by darryladie »

Are you using CSS to style your pages? If you are then use:

<link rel="stylesheet" src="style.css" media="handheld" />
<link rel="stylesheet" src="style.css" media="screen" />

If you wanna design for the PSP as well you need to check for user Agent: "Mozilla 3.0"

Darryl
Post Reply