Use a PHP program to display the viewer's display resolution

Source: Internet
Author: User
Tags date php file php code
Program | resolution | display This tutorial belongs to the original, reproduced please indicate the Web page teaching network

Today, we made a browser to display the screen resolution of the PHP code, I hope you use it, have any questions please go to the forum post discussion.

First create a new file named: resolution.php the contents of the code are as follows: ( Note: The file name extension must be. PHP is not. HTML)

<script language= "JavaScript" >
<!--
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_res=" + screen.width + "x" + screen.height;
var The_cookie = The_cookie + "; expires=" + the_cookie_date;
Document.cookie=the_cookie

location = ';
}

function checkres (width, height) {
if (width!= screen.width | | height!= screen.height) {
Writecookie ();
} else {
return true;
}
}
-->
</script>


<script language= "JavaScript" >
<!--
Checkres (1024, 768);
-->
</script>



Web page Teaching Network http://www.webjx.com Web Designer's Cradle!!

Next, put the following code where you want to display the visitor's display resolution information! (The following code, of course, is also placed in the extension. PHP file)

<?php
$callget_res_page_name = $request_uri;
$globals[callget_res_page_name] = $callget_res_page_name;
Include ("resolution.php");
echo $screen_width. " X ". $screen_height." Is your screen resolution. ";
?>

Note: $ should be half a corner.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.