如何使用 PHP 获取用户的屏幕分辨率
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4180134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to get user's screen resolution with PHP
提问by Moon
Possible Duplicate:
Getting the screen resolution using PHP
可能的重复:
使用 PHP 获取屏幕分辨率
well the question is self explanatory
这个问题是不言自明的
where i want to reach is
我想到达的地方是
$width = ; //user screen width in here
F1! F1!
F1!F1!
回答by Matt Ball
You need JavaScript, not PHP.
您需要 JavaScript,而不是 PHP。
var screenWidth = window.screen.width,
screenHeight = window.screen.height;
You can then send it to the server via Ajax (with an XmlHttpRequest
).
然后,您可以通过 Ajax(带有XmlHttpRequest
)将其发送到服务器。
See also the MDC window.screen
docs.
另请参阅MDCwindow.screen
文档。
回答by Femaref
You can't, not in php. PHP is strictly server-side.
你不能,不是在 php 中。PHP 是严格的服务器端。
回答by jcomeau_ictx
you can't get it server-side, you have to get it client-side with javascript with innerWidth. you can pass it to the server-side with AJAX if you need to.
你不能在服务器端得到它,你必须用带有innerWidth的javascript在客户端得到它。如果需要,您可以使用 AJAX 将其传递给服务器端。
回答by frend
You can use JavaScript. Get the user's screen, send it to the server and get it by php.
您可以使用 JavaScript。获取用户的屏幕,发送到服务器,通过php获取。