PHP's or
works like C's ||
(which incidentally is also supported by PHP - or
just looks nicer and has different operator precedence - see this page).
It's known as a short-circuit operator because it will skip any evaluations once it has enough information to decide the final value.
In your example, if mysql_connect()
returns TRUE, then PHP already knows that the whole statement will evaluate to TRUE no matter what die()
evalutes to, and hence die()
isn't evaluated.
If mysql_connect()
returns FALSE, PHP doesn't know whether the whole statement will evaluate to TRUE or FALSE so it goes on and tries to evalute die()
- ending the script in the process.
It's just a nice trick that takes advantage of the way or
works.