Can PHP tell if the server os is 64-bit?

后端 未结 12 591
北荒
北荒 2020-12-09 08:52

I am dealing with Windows here.

I know you can use the $_SERVER[\'HTTP_USER_AGENT\'] variable to detect the OS of the browser viewing the page, but is t

12条回答
  •  悲&欢浪女
    2020-12-09 09:15

    No need to do calculations. Just check the PHP_INT_SIZE constant:

    if(PHP_INT_SIZE>4)
      // 64 bit code
    else
      // 32 bit code
    

    The size of integers is a good indicator, but not bulletproof. Someone might run a 32 bit app on a 64 bit system.

    $_SERVER['SERVER_SOFTWARE'] and $_SERVER['SERVER_SIGNATURE'] might tell you something useful, depending on the implementation of the server.

提交回复
热议问题