how to detect mobile screen size

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

7 replies · 2,016 views · started 15 years ago · 1 min read

7 participants
GumSlone Administrator Principal · 1,690 posts #4

Sifat3d wrote: How can i detect the mobile users screen size using php? I know it has something to do with UA,but please anyone help me.

google for tera wurfl or device atlas.

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

wapmaza Newbie · 6 posts #5

i want .php code for screen size detection not java script

arnage Lead · 811 posts #6

PHP it self can't detect screen resolution.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
achinixp Newbie · 4 posts #8
<?php

if(isset($HTTP_COOKIE_VARS["users_resolution"]))
$screen_res = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();

function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie

}
//-->
</script>
<?
}

echo "Your screen resolution is set at ". $screen_res;
?>

use [ php ] tag [ / php ] for posting code

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