php在if else语句中构建if语句



我已经在if/else语句的" else"中创建了一个if语句。功能运行。请您帮助我。

此代码引起问题:

<?php $googleplay= get_option('director_googleplay');?>
<?php if($googleplay): ?>
    <a href="<?php print $googleplay; ?>">
       <img src="<?=IMAGES?>/googleplay.png" class=" img-responsive  top-buffer-5"  alt="Image"/>
    </>
<?php endif;;?> 

php:

<?php  $category_id = get_cat_ID('Category Name'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php if ( in_category("1") ) { ?>
       <div class="section"></div>
    <?php } elseif ( in_category("2") ) { ?>
       <div class="section"></div>
  <?php } else { ?>
      <div class="section">
          <?php $googleplay= get_option('director_googleplay');?>
          <?php if($googleplay): ?>
              <a href="<?php print $googleplay; ?>"><img src="<?=IMAGES?>/googleplay.png" class=" img-responsive  top-buffer-5"  alt="Image"/></>
          <?php endif;;?> 
       </div>
    <?php } ?>
<?php endwhile;else: ?>
    <p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
<div class="section">
    <?php $facebook= get_option('director_facebook');
    <?php if($facebook): ?>
    <a href="<?php print $facebook; ?>"><img src="<?=IMAGES?>/Facebook.png" class=" img-responsive pull-left"alt="Image"/></>
    <?php endif; ?>
</div>

好吧,您忘了关闭<a> -TAG:</a>,而不是</>。但是,代码仍应"运行",只需显示垃圾。

此外,PHP片段也可以由<? -TAG启动和结束,您的代码中有一个:

<img src="/googleplay.png" class=" img-responsive top-buffer-5" alt="Image"/>

应该工作。删除可能导致问题的<?=IMAGES?>。您想用<?=IMAGES?>做什么?

最新更新