Can anyOne Combain It Plz ???

Started on the old forum in March 2011 · view the original in the archive · old links redirect here

1 reply · 482 views · started 15 years ago · 1 min read

FrOsT-BiTe #1

This code will detect mobile name by default browser.

<?php 
$mobile = strtok(getenv('HTTP_USER_AGENT'), "/");
echo $mobile;
?>

This code detect mobile model number while u using operamini.

<?
$mobile = strtok(getenv('HTTP_X_OPERAMINI_PHONE_UA'), "/");
echo $mobile;
?>

Can Anyone Plz Combine Both Code as One ?

Like......

if From Default Browser, output will : Browser: n97

Or

if User From Opera Mini, Output will.. Browser: Opera/9.80 Opera Phone: N97

Plz Help.. Thank You

GumSlone Administrator Principal · 1,690 posts #2
<?php 
if(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']))
$browser = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
else
$browser = $_SERVER['HTTP_USER_AGENT'];
$mobile = strtok($browser, "/");
echo $mobile;
?>

or

<?php 
if(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']))
{
$mobile = strtok($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'], "/");
echo $mobile;
}
$mobile = strtok($_SERVER['HTTP_USER_AGENT'], "/");
echo $mobile;
?>

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close