Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2004, 06:05 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default Detect Resolution

How Do I Detect Screen Resolution using PHP ?
I don't wanna use Macromedia MX code -n- MM variables.
I am using notepad.
__________________
`~@#\^%&*/\.<.\/-|+|_!:;..=?>
PHP, SEO | anshul shrivastava | mediasworks.org | FB
 
Old April 3rd, 2004, 04:16 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

This is not possible with PHP.

PHP is a server-side language and in most cases (the server) is provided with little or no information about the client's machine requesting information. That is to say little beyond what is offered in various $_SERVER variables like $_SERVER["HTTP_USER_AGENT"], or $_SERVER['REMOTE_ADDR'] and other such variables.

To see what information is available run a PHP info script.

<?php
    phpinfo();
?>

This is, however, possible on the client-side using JavaScript.. once gathered it can then be passed to PHP.

Do a google search:
http://www.google.com/search?q=javas...een+resolution

: )
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old April 7th, 2004, 05:14 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

pass JavaScript variables to .php file:

<?php
if (isset($_GET['width']) AND isset($_GET['height'])) {
  // output the geometry variables
  echo "Screen width is: ". $_GET['width'] ."<br />\n";
  echo "Screen height is: ". $_GET['height'] ."<br />\n";
} else {
  // pass the geometry variables
  // (preserve the original query string
  // -- post variables will need to handled differently)

  echo "<script language='javascript'><!--\n";
  echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}"
            . "&width=\" + screen.width + \"&height=\" + screen.height;\n";
  echo "//--></script>\n";
  exit();
}
?>

from online documentation of php.net

 
Old April 7th, 2004, 05:16 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

This is not, however, PHP actually doing the detecting. If the client has disabled JavaScript, this will not work.

----------
---Snib---
----------

<><





Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript detect screen resolution crmpicco Javascript How-To 1 September 19th, 2005 06:07 AM
Resolution Ioan VB How-To 1 May 23rd, 2005 09:04 AM
screen resolution Adam H-W Classic ASP Basics 3 October 13th, 2004 09:13 PM
How to detect screen resolution pb_user Classic ASP Basics 1 August 24th, 2003 01:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.