It’s neither 0x nor 0; what is it? Is there?
It’s neither 0x nor 0 ; what is it? Is there?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As of PHP 5.4+ the prefix for binary number is:
For ealier version, there is no such prefix. Instead, you can use `0x`, for hexadecimal.
For more informations, see the Integers section of the PHP manual.
Still, if you really need to write values using binary before PHP 5.4, you can use the
bindecfunction, that takes a string containing the binary, and returns the corresponding value.For example, the following portion of code :
Will get you :
But note you shouldn’t do that too often : calling a function to do that each time the script is executed is quite bad for performances ^^
Instead, it’s really a better solution to write your values using hexadecimal, where each digit codes for 4 bits.