[PHP]Detect the display resolution
PHP does not possess any function allowing detection of the display resolution.
The solution is to make use of Javascript to detect the resolution through the width and height attributes of the screen:
screen.width
screen.height
Thus the following code, once inserted into an HTML document:
<script language="Javascript">
<!--
document.write('<br>your resolution is'.screen.width+'x'+screen.height)
//-->
</script>
It is possible to switch the setting to a PHP script via Javascript.
<?
if(!isset($_GET['r']))
{
echo "<script language=\"JavaScript\">
<!--
document.location=\"$PHP_SELF?r=1&width=\"+screen.width+\"&Height=\"+screen.height;
//-->
</script>";
}
else {
// Code to be displayed if resolutoin is detected
if(isset($_GET['width']) && isset($_GET['Height'])) {
// Resolution detected
}
else {
// Resolution not detected
}
}
?>