开发者

PHP nested Ifs are not working

开发者 https://www.devze.com 2023-03-21 00:31 出处:网络
I\'m checking if Facebook users don\'t like a page. If so, the code displays the user\'s name and an invitation message to \"Like it\"; if not, it displays the \"incentive landing page\". However, I j

I'm checking if Facebook users don't like a page. If so, the code displays the user's name and an invitation message to "Like it"; if not, it displays the "incentive landing page". However, I just get the first part: the code doesn't show the "incentive" when users hit the Like button. The code looks like this:

<?php if(!$like_status): ?> 
    <?php if ($me)开发者_如何学Go: ?>
      <div id="name">Hola <?php echo $me['first_name']; ?></div> //Everything works fine.  
    <?php endif; ?>
     // Display graphics... Everything works fine.
<?php else : ?>
     //Page with the incentive... This does not work when the nested if is present.
<?php endif; ?>

If I get rid of the nested if (the one that displays the user's name), everything works fine. Any ideas?


You're missing your semicolon after the endif's

<?php if(!$like_status): ?>   
    <?php if ($me): ?>
      // Display user's name... Everything works fine.  
    <?php endif; ?>
     // Display graphics... Everything works fine.
<?php else: ?>
     //Page with the incentive... This does not work when the nested if is present.
<?php endif; ?>


In case somebody is facing the same problem, I found the solution: for some reason IE 7-8 doesn't like the variable $me and the call to the API('/me') in the same context. I just changed the name of the variable and everything works fine in FF, Chrome, and IE 7-9.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号