Why does this code return -1 ?
$a = 0; echo ~$a;
Isn\'t not suppose to revert the bits ?
Yes it should, and on the two's complement number system, a number with all bits set equals to -1 and since 0 has all bit unset, ~$a will have all its bit set.
So the code is behaving as expected.