Why is the result of & operation false?
凉伴伴
凉伴伴 2019-05-24 15:04:32
0
1
1083

$x = true;

$y=2;

if($x & $y) is false

if($x & 3) is true

凉伴伴
凉伴伴

reply all(1)
凉伴伴

Answer by yourself, you will understand after reading the next section [Bit Operations]. & and | are both digital operations. They will be operated in binary first and then judged.

$x and $y++ are converted to binary to 0, so The final result of $x & $y++ is 0, if(0)----false

3 converted to binary is 11, $x & 3 binary result is 011, converted to decimal is 3, if( 3)----True

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!