Following is my piece of code in which I am assigning my screen width to variable $width. But when I convert it to integer and echo it, 0 is returned.
$width = '<script> document.write(window.screen.width); </script>';
//if i echo $width it shows 1366 which is width of my screen
$height = '<script> document.write(window.screen.height); </script>';
echo "The height is = $height"."<br>The width is = ".$width;
$a = (int)($width);
echo $a;
I am asking for guidenance to make this conversion perfect.
You aren’t actually getting the screen dimensions at that time. That runs on the client. You will have to make an ajax call to the server to set it.