Checking if your code is running on 64-bit PHP

后端 未结 5 1235
梦如初夏
梦如初夏 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:26

    You could write a function like this:

    function is_32bit(){
      return PHP_INT_SIZE === 4;
    }
    

    Then you could use the sample code you posted:

    if ( is_32bit() ) {
        do_32bit_workaround();
    } else {
        do_everything_else();
    }
    

提交回复
热议问题