下記サイトサンプルを修正、実行後リダイレクトしデバイスのwidthとheightを取得。
https://stackoverflow.com/questions/23239157/get-browser-width-using-php
get_screensize.php
<?php
session_start();
if(isset($_POST['width'])){
$_SESSION['screen_size'] = array();
$_SESSION['screen_size']['width'] = intval($_POST['width']);
$_SESSION['screen_size']['height'] = intval($_POST['height']);
}
if(!isset($_SESSION['screen_size'])){
?>
<html>
<head>
<script>
function getSize(){
document.getElementById('inp_width').value=screen.width;
document.getElementById('inp_height').value=screen.height;
document.getElementById('form_size').submit();
}
</script>
</head>
<body onload='getSize()'>
<form method='post' id='form_size'>
<input type='hidden' name='width' id='inp_width'/>
<input type='hidden' name='height' id='inp_height'/>
</form>
</body>
</html>
<?php
}else{
//var_dump($_SESSION['screen_size']);
header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/screensize_out.php');
}
?>
screensize_out.php
<?php
session_start();
echo "閲覧中のディスプレイサイズは下記の通りです!!<BR>";
echo "width: ".$_SESSION['screen_size']['width']."<BR>";
echo "hight: ".$_SESSION['screen_size']['height'];
?>