以下は、画面幅を変数に割り当てているコードです$width
。しかし、整数に変換してエコーすると、0
返されます。
$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;
この変換を完璧にするためのガイダンスを求めています。