title: What's the function of the ~ bitwise operator (Tilde)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1967360/what-does-this-operator-mean-here">What does this ~ operator mean here?</a><br>
    <a href="https://stackoverflow.com/questions/8785054/bit-not-operation-in-phpor-any-other-language-probably">Bit not operation in PHP(or any other language probably)</a></p>
  </blockquote>
  
  
  
  <p>Can someone explain me the <code>~</code> operator in PHP? I know it's a <a href="http://www.php.net/manual/en/language.operators.bitwise.php" rel="noreferrer">NOT-operator</a>, but why does PHP convert following statement to the negative value of the variable minus one?</p>
  
  <pre><code>$a = 1; echo ~$a    // echo -2
  $a = 2; echo ~$a    // echo -3
  $a = 3; echo ~$a    // echo -4  
  </code></pre>