Getting the screen resolution using PHP

前端 未结 21 2399
你的背包
你的背包 2020-11-22 06:50

I need to find the screen resolution of a users screen who visits my website?

21条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 07:05

    In PHP there is no standard way to get this information. However, it is possible if you are using a 3rd party solution. 51Degrees device detector for PHP has the properties you need:

    • $_51d['ScreenPixelsHeight']
    • $_51d['ScreenPixelsWidth']

    Gives you Width and Height of user's screen in pixels. In order to use these properties you need to download the detector from sourceforge. Then you need to include the following 2 lines in your file/files where it's necessary to detect screen height and width:

    
    

    Where path/to/core is path to 'Core' directory which you downloaded from sourceforge. Finally, to use the properties:

    
    

    Keep in mind these variables can contain 'Unknown' value some times, when the device could not be identified.

提交回复
热议问题