I have find the way to print current window size with using js and php but when i execute with function it won't works. Any one please help.
<?php $currentwidth
= " <script>
document.write(window.innerWidth); </script>
";
echo $currentwidth; //works fine but belowis not working
if ( $currentwidth <= "480" ) { echo "TRUE"; } else { echo "FALSE"; }; ?>
Asked
Active
Viewed 292 times
1

Raha MK
- 102
- 3
- 16
-
you should use jquery post, and with it post values to the php file – Aleksandar Vasić Aug 06 '15 at 10:21
-
1Javascript is a client side script. Php is server side scripts. In this case you can not assign JS result to php – Sajitha Rathnayake Aug 06 '15 at 10:25
-
Like I said in my incorrect answer, this post can help you : http://stackoverflow.com/questions/1504459/getting-the-screen-resolution-using-php – Mteuahasan Aug 06 '15 at 14:11
1 Answers
1
You are mixing up javascript and php. javascript runs in browser and php runs in server. If you want php to print something you have to send the value to the server.

Crunch Much
- 1,537
- 1
- 11
- 14