I want to print a string based on screen width in PHP using Javascript. If screen size is less than or equal to 400 then, echo will print "Mobile". If it is not then it will print "Desktop". But it is always printing Desktop. I also want to echo the value of screen width to ensure that it is measuring correctly.
This is my code.
<?php
$screenWidth = '<script type="text/javascript">document.write(screen.availWidth);</script>';
echo $screenWidth; //I want to echo the value. But it is not coming.
if ($screenWidth <= "400")
echo 'Mobile';
else
echo 'Desktop';
?>