&& is and , what does one mean? It seems that it is not passed by reference, and then the result is 3. I don’t quite understand. Can anyone explain 2 sentences to me? Thank you
<code><?php function test_odd($var) { return($var & 1); } $a1=array("a","b",2,3,4); print_r(array_filter($a1,"test_odd")); ?> 打印结果Array ( [3] => 3 )</code>
&& is and , what does one mean? It seems that it is not passed by reference, and then the result is 3. I don’t quite understand. Can anyone explain 2 sentences to me? Thank you
<code><?php function test_odd($var) { return($var & 1); } $a1=array("a","b",2,3,4); print_r(array_filter($a1,"test_odd")); ?> 打印结果Array ( [3] => 3 )</code>
PHP’s bitwise operator - bitwise AND, test_odd is a function that determines odd numbers.
But there is a very important sentence in this paragraph that is in English. Let me translate it:
If the two operands of
&
,|
,^
are both strings, then the string will be converted into the corresponding ascii code first and then the bit operation will be performed. If it is other cases, then They are all converted into integers and then performed bit operations.
So even though the ascii code of a
is 97, it will still be filtered out.