This is sometimes known as the ternary conditional operator. Ternary means that it has three arguments, as x ? y : z
. Basically, it checks if x
is true; if it is, then put y
instead of this operation, otherwise z
.
$hello = $something ? "Yes, it's true" : "No, it's false";