$hideCode = $likesObj->isAlreadyLikedByUser(facebookUID()) ? \'style=\"display:none;\"\' : \'\';
Can anyone explain to me what that question mar
This is called the Ternary Operator, and it's common to several languages, including PHP, Javascript, Python, Ruby...
$x = $condition ? $trueVal : $falseVal;
// same as:
if ($condition) {
$x = $trueVal;
} else {
$x = $falseVal;
}
One very important point to note, when using a ternary in PHP is this:
Note: Please note that the ternary operator is a statement, and that it doesn't evaluate to a variable, but to the result of a statement. This is important to know if you want to return a variable by reference. The statement return $var == 42 ? $a : $b; in a return-by-reference function will therefore not work and a warning is issued in later PHP versions. source