I want to get in PHP the height/width of both the screen and the viewport when a user visits a page.
I\'ve tried different ways but they all cause other problems.
I think it's better to ask yourself: What do you want to do with the width
and height
? And look if there are other ways to accomplish that goal. You cannot get the user his screen width and height using PHP because it runs server-side.
So this data is never available on the first load.
You could submit the data using AJAX and then make the changes to the page using JavaScript. Then the next page reload the data is, when stored, server-sided available.