Checking if your code is running on 64-bit PHP

后端 未结 5 1240
梦如初夏
梦如初夏 2020-11-29 05:09

Does anyone know of a way of checking within PHP if the script is running as either 32-bit or 64-bit? Currently I\'m using PHP 5.3.5.

Ideally I\'d like to write a f

5条回答
  •  鱼传尺愫
    2020-11-29 05:47

    Here is an example that can be used from console

    For Windows:

    php -r "echo (PHP_INT_SIZE == 4 ? '32 bit' : '64 bit').PHP_EOL;" && php -i | findstr Thread
    

    For Linux

    php -r "echo (PHP_INT_SIZE == 4 ? '32 bit' : '64 bit').PHP_EOL;" && php -i | grep Thread
    

    Output example:

    64 bit
    Thread Safety => disabled
    

提交回复
热议问题