Pyh.conf’25: a new PHP conference for the Russian-speaking community

Voting

: six plus two?
(Example: nine)

The Note You're Voting On

aba at example dot com
13 years ago
It is true that if both the left-hand and right-hand parameters are strings, the bitwise operator will operate on the characters' ASCII values. However, a complement is necessary to complete this sentence.
It is not irrelevant to point out that the decimal character's ASCII value have different binary values.

<?php
if (('18' & '32') == '10') {
echo
ord('18'); //return decimal value 49, which have binary value 110001
echo ord('32'); //return decimal value 51, which have binary value 110011
echo ord('10'); //return decimal value 49, which have binary value 110001
//Therefore 110001 & 110011 = 110001
}
?>

<< Back to user notes page

To Top