Find Screen Resolution With PHP
I think there is no way yet to find out screen resolution with PHP. hehehe.
If I am wrong please correct me.
But yet we can trick it to be happen ;-)
If not then how can we be developers. Right!
With javascript we find out screen resolution of PC. Store it in a cookie and display it with PHP.
Coool…eh! Fine, lets just do it baby.
<script LANGUAGE="javascript"> width = screen.width; height = screen.height; document.write("<b>You're set to "+width+ "X" +height+"</b>") </script>
<?php $yo=$_GET['width']; echo $yo; ?>
For head section of webpage.
<? 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 location = 'screen.php'; } //--> </script>
<? } ?>
Body section of webpage. Display the screen resolution.
<?php echo "Your screen resolution is set at ". $screen_res; ?>
Enjoy!!! …Chill Pill…
Tags: Checks, Resolution, screen, useful
Posted in: Checks, Cookies, Tricks, Useful Scripts
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0
Posted in: Checks, Cookies, Tricks, Useful Scripts
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0

Rkey Says:
Well, this approach a bit complicated.
Here is a much simpler hack:
$sw = “document.write(screen.width)”;
$sh = “document.write(screen.height)”;
print $sw;
print $sh;
King Says:
@Rkey: Thanks RKey.