-2

i try to get screen width in php using javascript , it is return it in string type . I can't using if statment for chose best ad size for screen

    $screenwidth = '<script>
    document.write(window.innerWidth)
    </script>';
    $nu = (int)$screenwidth;
    echo $nu;

Any Help

1 Answers1

0

you can't get window size in php your code means

<html>
   <head></head>
   <body>
      <script>docuemnt.write(window.innerWidth);</script>
   </body>
</html>

and it's work when you echo $screenWidth in your page and then that print window size.

so in php that is just a string.