$hideCode = $likesObj->isAlreadyLikedByUser(facebookUID()) ? \'style=\"display:none;\"\' : \'\';
Can anyone explain to me what that question mar
Actually this statment is representing a Ternary operation, a conditional expression:
// works like: (condition) ? if-true : if-false;
$hideCode = $likesObj->isAlreadyLikedByUser(facebookUID()) ? 'style="display:none;"':'';
in your case $hideCode
will have style="display:none;"
value if
$likesObj->isAlreadyLikedByUser(facebookUID())
will return true, else it will be null or empty.
$hideCode = $likesObj->isAlreadyLikedByUser(facebookUID()) ? 'style="display:none;"':'';
This is the same as the following:
if ($likesObj->isAlreadyLikedByUser(facebookUID()))
{
$hideCode = 'style="display:none;"';
}
else
{
$hideCode = '';
}
It's a shorter version of a IF statement.
$hideCode = $likesObj->isAlreadyLikedByUser(facebookUID()) ? ' style="display:none;"':'';
if in fact :
if($likesObj->isAlreadyLikedByUser(facebookUID()))
{
$hideCode = 'style="display:none"';
}
else
{
$hideCode = "";
}
For the purism :
It's representing a Ternary operation
This is the simple if-then-else type logic:
(condition) ? (if-true-value) : (if-false-value)
so in your case, the condition is checked (i.e. has the page already been liked by the user); if yes (true condition), then style="display:none;"
is printed so that whatever the element you're using is not displayed. Otherwise, an empty string is printed, which is the equivalent of not printing anything at all, naturally.
It's part of a ternary operator. The first part is the conditional of an if-else statement. After the question mark is the "if" block, and after the colon is the "else" block.
It is the ternary operator: it means
if $likesObj->isAlreadyLikedByUser(facebookUID())
is true assign style="display:none;
to the variable, otherwise assign ''