How do I get the screen resolution using PHP?
The screen resolution of the server or the client?
To get the resolution of the server you would have to use the exec() function and execute the unix/dos command to get the resolution (are there any?)
But you probably mean the client, which you would use JavaScript
You can write the resolution to a cookie and use the php cookie functions to grab the resolution from the cookie file.Code:<script type="text/javascript"> document.write(window.screen.width + ' x ' + window.screen.height); </script>
To get the client records you will need to use Javascript and there is no way that PHP can receive this value since it is server side.
Hmm, I really just need to make an if statement and if their resolution is lower than a certain value display an error message. Do I need to do a cookie and everything for that?
How would you compare the value?
Im pretty sure if you want to use php to display the error message you have to use cookies, unless there is another way to store the width/height. You could always of course display the error in JavaScript. Im no JS expert but maybe something like thisCode:if(<script type="text/javascript">
document.write(window.screen.width + ' x ' + window.screen.height);
</script> < 1024)
echo "Error";
Code:<script type="text/javascript"> if(window.screen.width < 1024) allert("Your screen is too small"); </script>
What Sidewinder suggested would work well. You could also create a dynamic page using JavaScript or simply forward the user to an error page (like res.html) with the same logic above.
That works. I'll figure out something. Thank you.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks