dotMobimobiThinkingmobiForgemobiReadyDeviceAtlasgoMobi

Posted by coryj_canada 4 years 47 weeks ago

pic
 coryj_canada
mobiForge Newbie
Posts: 2
Joined: 4 years ago
[offline]

Hey everyone, I saw that no one has posted here yet, so i though this might be a good place to start :)
I have created a php based detection script for mobile sites. Most of the mobile sites I create are usually housed in a /mobile/ folder within the main site (long story... don't ask ;)). So if both sites are with in the same domain I thought i would be easy to detect whether the person visiting the site was either a computer or a mobile device. So here what I came up with:
Basically I do a preg_match search in the $_SERVER variable (remembering that this is php, asp and jsp are different).
preg_match(My pattern, $_SERVER array) -> so it likes this preg_match("/http_(x|ua)_.*?/Ai",$_SERVER)

The regular expression searches the array keys for anything that matchs HTTP_X_ or HTTP_UA_
Only mobile browsers will set a HTTP_X variables and only Windows Mobile devices will set the HTTP_UA variables.

So far this as proved to work for ever device I have tested, including Opera Mini which is gain great momentum in the mobile industry. Please let me know what you think, or if you have any questions... ask away!!

Cheers!

Posted by mobip 4 years ago

pic
 mobip
mobiForge Newbie
Posts: 1
Joined: 4 years ago
[offline]

Coryj_canada,

I have just started to research designing websites for mobile phones.

I'm trying to design a site that low end cell phones can access with opera or openwaves mobile browser, and high phones like smart phones can access with opera , pocket ie & palms default browser.

For instance I can access msn.mobi on smartphone and msn.mobi displays itself with graphs and text. However when I review the same site on mobile browser i can only review text from msn.mobi.

So can you guide me to a few websites or some code to play around with.

Cheers!!!

Posted by andymoo 4 years ago

pic
 andymoo
mobiForge Enthusiast
Posts: 19
Joined: 5 years ago
[offline]

PHP to detect mobile phones
Comments welcome.
Andy Moore

Andy Moore
dotMobi Certified Mobile Web Developer
Mp3 downloads

Posted by gracetime 4 years ago

pic
 gracetime
mobiForge Newbie
Posts: 1
Joined: 4 years ago
[offline]

Hi Carey..
I like your script... so much I did try it .. What I wanted to do is simply detect if a mobile hit the web page or not.. If it is a "cell phone / mobile I wanted to divert to a mobi page.. if not to a std html or other. Alas.. I didnt seem to get it to go.. It always wanted to divert based on a pc connection basis..
Other words I probably didnt do something right but experimented with a cell phone simulator (found at http://emulator.mtld.mobi/emulator.php ) and of course a std pc.

I realize your code results in a value for pc or mobile.. but how would one get it to divert based on one or the other? Any ideas?

Posted by zhaochina 4 years ago

pic
 zhaochina
mobiForge Newbie
Posts: 3
Joined: 4 years ago
[offline]

i have tested it on my php program. but there is one waring. also no display. Please help me. thanks a lot.
..................................
if(preg_match("/http_(x|ua)_.*?/Ai",$_SERVER))
echo "1";
else
echo "2";
..................................
waring inormation:
.......................................
Warning: preg_match() expects parameter 2 to be string, array given in E:\Visual Projects\test.php on line 34
....................................................................

Sam zhao

Posted by luizpaulo 4 years ago

pic
 luizpaulo
mobiForge Newbie
Posts: 1
Joined: 4 years ago
[offline]

try this:

if(preg_match("/http_(x|ua)_.*?/Ai",implode(' ',$_SERVER))) {
echo "1";
} else {
echo "2";
}

hope it helps.

Posted by dryabov 4 years ago

pic
 dryabov
mobiForge Newbie
Posts: 5
Joined: 4 years ago
[offline]

Only mobile browsers will set a HTTP_X variables
Most proxies normally pass an extra HTTP variable called HTTP_X_FORWARD which will actually reveal the real IP
address.

Posted by john_sharma (not verified) 3 years ago

pic
 
Mobile Master
Posts: 82
Joined:
[offline]

hi,
can any body tell me that how to detect latest mobile phones using php? i have tried many codes including andy moore it works for limited browser like Nokia N70, Nokia 3250 but any script doesn't detect Nokia N80 and Nokia N95.

if any body knows about paid class which detect mobile device please help me

Posted by atrasatti 3 years ago

pic
 atrasatti
dotMobi logo
Mobile Genius
Posts: 325
Joined: 5 years ago
[offline]

dotMobi offers a product called DeviceAtlas. You can get a developer licence for free so that you can install it, play with it and then decide if it suits you. Use your dev.mobi account to login.

You might also want to check out a quick script that Russell Beattie wrote, see Mobile Browser Detection in PHP.

Posted by wap 3 years ago

pic
 wap
mobiForge Newbie
Posts: 5
Joined: 3 years ago
[offline]

hello friend
any idea about php with wap2.0 please give that.

Posted by alanc888 2 years ago

pic
 alanc888
mobiForge Newbie
Posts: 1
Joined: 2 years ago
[offline]

Tried detection script from easymobilizer.com - have found no probs - javascript, place in head - has fork to /mobile or whatever you use