title: PHP strange bitwise operator impact on strings
body: <h1>Update.. moved to a <a href="https://stackoverflow.com/questions/6400361/bitwise-operation-result-strange-behavior-when-outputted">new question</a>.</h1>
  
  <p><strike>Okay, after reading PHP documentation it's clear now with those bitwise operators, but, huh, what is this?</p>
  
  <pre><code>#dump1
  var_dump('two identical strings' | 'two identical strings'); // mind the |
  // string(21) "two identical strings"
  
  #dump2
  var_dump('two identical strings' ^ 'two identical strings'); // mind the ^
  // string(21) ""
  </code></pre>
  
  <p><strong>Why <code>#dump2</code> shows that length == 21, but 0 characters?</strong>  </p>
  
  <p>When copied in Notepad++ there are no signs of characters inside the string, so, how come <code>strlen &gt; 0</code>? - this confuses me, because Notepad++ can show some kind of bit-level (at least I think that those are bit-level, correct me if I'm wrong) characters, see picture:
  <img src="https://i.stack.imgur.com/AZbJl.gif" alt="enter image description here"></p>
  
  <p>This is actually result from:</p>
  
  <pre><code>$string = 'i want you to compare me with an even longer string, that contains even more data and some HTML characters, like &amp;euro; ' ^ 'And I am going to add some HTML characters, like &amp;euro; again to this side and see what happens'; // mind the ^
  var_dump(htmlentities($string)); // had to add htmlentities, otherwise &amp;gt; (&lt;) characters are added in this case, therefore messing up the output - Chrome force closes `&lt;body&gt;` then
  // string(101) "(NA'TAOOGCP MI&lt;&lt;m-NC C IRLIHYRSAGTNHEI   RNAEAAOP81#?"
  </code></pre>
  
  <h2>i'd love to see this #dump2 related question answered, thanks in advance!</strike></h2>
  
  <hr>
  
  <p>While experimenting, I found out this:</p>
  
  <pre><code>echo 'one' | 'two'; 
  // returns 'o'
  
  echo 'one' | 'twoe';
  // returns 'oe'
  </code></pre>
  
  <p>So, seeing that in those two lines it returns only letters which are in both strings, I was thinking it does some comparison or something:</p>
  
  <pre><code>echo 'i want you to compare me' | 'compare me with this';    
  #crazy-line // returns 'koqoveyou wotko}xise me'
  </code></pre>
  
  <p>While writing this, even stranger stuff happened. I copied that returned value, and after pasting it into post textarea, when pointer is positioned at the end of <code>crazy-line</code>, it is actually one "space" to the right not where it should be. When backspacing, it clears last character, but pointer is still one "space" to the right.</p>
  
  <p>That lead me to copy this value inside Notepad++:<br>
  <img src="https://i.stack.imgur.com/4YZY3.gif" alt="returned value inside Notepad++"><br>
  And, huh, as you can see there is a 'boxy' character within this string that doesn't show up inside browser (at least on mine, Chrome, latest). And yes, when this character is removed from that string (by backspacing), it returns back to normal - no more "space" to the right.</p>
  
  <p><strike><strong>So, first, what is this <code>|</code> inside PHP, and why there is such a strange behavior?</strong></p>
  
  <p><strong>And what is this even stranger character, that looks like a box and doesn't show up in browser?</strong></strike></p>
  
  <p>I'm pretty damn curious why this is happening, so here is one more test with longer strings containing HTML entities:</p>
  
  <pre><code>$string = 'i want you to compare me with an even longer string, that contains even more data and some HTML characters, like &amp;euro; ' | 'And I am going to add some HTML characters, like &amp;euro; again to this side and see what happens';
  var_dump($string);
  // returns string(120) "inwaota}owo}ogcopave omwi||mmncmwwoc|o~wmrl{wing}r{augcontuonwhmweimorendaweealawomepxuo characters, like € "
  </code></pre>
  
  <p>Last value contains 7 of those 'boxy' characters.</p>