0

I am trying to get a better understanding of PHP and JS, and decided to take this simple function.

    <script>
        function getScreenResolution() {
            var screenResolutionW = screen.width; 
            var screenResolutionH = screen.height;
        }
    </script>

I would like to know how I could "convert" this to a PHP function, so that I can write this screen.width and screen.height information to a log.txt using PHP like so:

$fh = fopen('log.txt', 'a');
fwrite($fh, 'Screen res: '."".$screenResolutionW. 'x'."".$screenResolutionH  ."\r\n");
fclose($fh);
Buster
  • 446
  • 5
  • 16
  • PHP is server sided, getting the width and height is client sided, so you have to do a call to the server after getting the variables – Merijndk May 01 '20 at 10:57
  • you need to send an AJAX request to the server, and send that height/width data in the request. Then a PHP script can run, read the input data and log it to a file. – ADyson May 01 '20 at 11:23
  • @ADyson Yes, that's what I am trying right now. Thanks :) – Buster May 01 '20 at 11:27

0 Answers0