PHP question mark

前端 未结 7 1617
北荒
北荒 2020-12-31 02:29
$hideCode = $likesObj->isAlreadyLikedByUser(facebookUID()) ? \'style=\"display:none;\"\' : \'\';

Can anyone explain to me what that question mar

7条回答
  •  无人及你
    2020-12-31 03:03

    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.

提交回复
热议问题