the bitwise operators are actually working on the binary representation of your ascii characters... so none of your expressions actually work.... the first two work by accident with the ascii character set
when you write
'0001'
the bitwise operators see
0x48 0x48 0x48 0x49
'0' is 0x48 in hex = 0100 1000 binary
'1' is 0x49 in hex = 0100 1001 binary
so in char form
'0' & '1' = 0x48 & 0x49 = 0x48 = '0'
'1' & '1' = 0x49 & 0x49 = 0x49 = '1'
'0' & '0' = 0x48 & 0x48 = 0x48 = '0'
'0' | '1' = 0x48 | 0x49 = 0x49 = '1'
'1' | '1' = 0x49 | 0x49 = 0x49 = '1'
'0' | '0' = 0x48 | 0x49 = 0x48 = '0'
but when you get to the ^ xor
'0' ^ '1' = 0x48 ^ 0x49 = 0x01 = SOH
'1' ^ '1' = 0x49 ^ 0x49 = 0x00 = NULL
'0' ^ '0' = 0x48 ^ 0x49 = 0x00 = NULL
neither SOH or NULL are characters that your browser can display
ascii table reference at:
http://www.asciitable.com/
<?php
$string1 = "0101";
$string2 = "1001";
$int1 = 0x48;
$int2 = 0x49;
print " {$string1} & {$string2} = ". ($string1 & $string2)."<BR>";
print " {$string1} | {$string2} = ". ($string1 | $string2)."<BR>";
print " {$string1} ^ {$string2} = ". ($string1 ^ $string1)."<BR><BR>";
print " {$int1} & {$int2} = ". ($int1 & $int2)."<BR>";
print " {$int1} | {$int2} = ". ($int1 | $int2)."<BR>";
print " {$int1} ^ {$int2} = ". ($int1 ^ $int1)."<BR>";
?>