Get visitor screen resolution using PHP
- Code: Select all
function client_screen()
{
if(!isset($_GET['screen_check']))
{
/* This code will be executed if screen resolution has not been detected.*/
echo "<script language='JavaScript'>
<!--
document.location=\"$PHP_SELF?screen_check=done&Width=\"+screen.width+\"&Height=\"+screen.height;
//-->
</script>";
}
else
{
/* This code will be executed after screen resolution is detected.*/
if(isset($_GET['Width']) && isset($_GET['Height'])) {
// Resolution detected
return $_GET['Width']." x ".$_GET['Height'];
}
else {
// Resolution not detected
return 'Resolution not detected';
}
}