can php detect client browser monitor size/resolution? can php detect client browser monitor size/resolution? php php

can php detect client browser monitor size/resolution?


No, it cant. PHP runs on the server, so it cant detect client settings unless you take specific client-side steps to pass the info to the PHP scripts on the server.


Please do note that some of us like our browsers non-maximized. Perhaps you'd be better off trying to detect browser size rather than screen resolution. I assume that the JS to do either would be very similar, but I don't actually know that to be the case.

Also, what is the resolution of a blind man's screen reader?


You'll have to use PHP together with JavaScript, like in this example:

$url = $_SERVER['PHP_SELF'];if( isset($HTTP_COOKIE_VARS["res"]) )    $res = $HTTP_COOKIE_VARS["res"];else {    ?>    <script language="javascript">    <!--    go();    function go()     {        var today = new Date();        var the_date = new Date("August 31, 2020");        var the_cookie_date = the_date.toGMTString();        var the_cookie = "res="+ screen.width +"x"+ screen.height;        var the_cookie = the_cookie + ";expires=" + the_cookie_date;        document.cookie=the_cookie            location = '<?echo "$url";?>';    }    //-->    </script>    <?php}//Let's "split" the resolution results into two variableslist($width, $height) = split('[x]', $res);//Take the width and height minus 300$tb_width = $width-300;$tb_height = $height-300;//Make the tableprint("<table align=center border=1 width=" .$tb_width . " height=" . $tb_height . " >    <tr><td align=center>Your screen resolution is " . $width . " by " . $height . ".<br>    The width/height of this table is " . $tb_width . " by " . $tb_height . ".</td></tr>    </table>");