【问题标题】:Parse error: syntax error, unexpected 'endif' (T_ENDIF)?解析错误:语法错误,意外的“endif”(T_ENDIF)?
【发布时间】:2018-11-06 18:10:49
【问题描述】:

我在使用 php endif 时遇到错误,找不到错误。在这里,我给出了我的代码。请帮我解决这个问题

       <?php if( have_rows('home-video-slider') ): ?>
            <?php while( have_rows('home-video-slider') ): the_row(); 
              $video_banner = get_sub_field('video-banner');
             ?>
             <div class="item">
                <div class="fm-video-banner">
                        <?php if( $video_banner ); ?>
                        <img  src="<?php echo $video_banner['url']; ?>"/>
                        <?php endif; ?>

                    <a class="popup-youtube fm-play-icon" 
                      href="https://www.youtube.com/embed/5ktgB9hlETw">
                        <span>
                            <i class="fa fa-play" aria-hidden="true"></i>
                        </span>
                    </a>
                </div>
            </div>
            <?php $p++; endwhile; ?>
     <?php endif; ?>

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    那里有错误的语法:

    <?php if( $video_banner ); ?>
    

    替换为

    <?php if( $video_banner ): ?>
    

    在 if 的条件之后写 ; 就像在写

    <?php
        if( $video_banner )
        {
            ; //Do nothing
        }
    ?>
    

    这意味着您有一个多余的endif;

    【讨论】:

      猜你喜欢
      • 2017-10-30
      • 2013-12-07
      • 2014-10-15
      • 1970-01-01
      • 2014-10-16
      • 2021-09-16
      • 2018-04-03
      • 2018-10-17
      • 2014-06-15
      相关资源
      最近更新 更多