A
A
agent11562016-09-20 10:10:40
Yii
agent1156, 2016-09-20 10:10:40

How to check screen width using php?

How to check screen width using php like media query?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
Cat Anton, 2016-09-20
@27cm

Browsers don't send this information in requests. Just send the width to the server with javascript, and check it there.
If you need not an exact value, but an approximate one, then you can use the User Agent to make an assumption about the user's device and, accordingly, about the screen width. Of course, with a big error.
Library to help: https://github.com/WhichBrowser/Parser

O
Oleg, 2016-09-20
@politon

Get it via js

screen.width //Ширина экрана
screen.height //Высота экрана

M
Maxim Timofeev, 2016-09-20
@webinar

If you really need it, then this:
the js page is loaded, it checks in localstorage a certain parameter in which bul. If false takes the screen size, writes to the session reloads the page and changes the parameter to true so that reloading only happens once, at the first login. Everything is now read in php session and data is taken from there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question