What happens is that, if $_POST['userid'] is set then $userid should get it's value. But if its not, $userid should get the value 43, and the $error variable should be set to true. And it sure works. But I don't really get what happens there. I just tried the $error = true | 43 by a coincidence, and it works, but I'm not sure if it's really the right way of doing it? Is this really correct syntax?
And if it is good syntax... Is it any way of making this even shorter? for example so I don't have to write $_POST['userid'] two times? So I could replace it with $1 or something like that.
The single pipe "|" is the bitwise "or" operator. So true is cast to an integer 1 ("1" in binary), while 43 in binary is "101011". So when those two values are used with the "|" operator, "Bits that are set in either $a or $b are set." (See PHP Bitwise Operators), the result is still binary "101011" which is 43. If you instead use 42 for the "default", you would find that $userid is still set to 43 because of that ones digit being set by the "true".
Oh, and the if is evaluating to true because you use the "==" comparison operator, which allows type-casting, so the 43 is considered "true" since it is non-zero. If you used the "===" is-identical-to operator, then it would fail since integer 43 is not the same type/value as a boolean true.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation