The example in this article describes the method of obtaining the screen parameters of the client computer in PHP. Share it with everyone for your reference. The specific analysis is as follows:
First of all, it needs to be explained that php is a server-side language and cannot obtain the width and height of the client's screen. However, a workaround is to obtain the width and height of the client's computer screen through the client script language JavaScript, and then pass it to the PHP script language in the form of ajax or cookie, so that PHP can obtain the width and height of the client's computer screen.
The method of obtaining the width, height, and resolution of the client computer through javascript is as follows:
High screen resolution: window.screen.height
Width of screen resolution: window.screen.width
Screen available workspace height: window.screen.availHeight
Screen available workspace width: window.screen.availWidth
The method passed to the php server is as follows:
Based on the above, the complete code to obtain the width, height and resolution of the client computer display screen through php is as follows:
I hope this article will be helpful to everyone’s PHP programming design.