Find Windows 32 or 64 bit using PHP

前端 未结 6 1554
清酒与你
清酒与你 2020-12-05 11:05

Is it possible to get the window processor bit?? I want to find the window processor bit using php?? I have coding to find the operating system and other properties. Kindly

6条回答
  •  温柔的废话
    2020-12-05 11:44

    A slightly shorter and more robust way to get the number of bits.

        strlen(decbin(~0));
    

    How this works:

    The bitwise complement operator, the tilde, ~, flips every bit.

    @see http://php.net/manual/en/language.operators.bitwise.php

    Using this on 0 switches on every bit for an integer.

    This gives you the largest number that your PHP install can handle.

    Then using decbin() will give you a string representation of this number in its binary form

    @see http://php.net/manual/en/function.decbin.php

    and strlen will give you the count of bits.

    Here is it in a usable function

    function is64Bits() {
        return strlen(decbin(~0)) == 64;
    }
    

提交回复
热议问题