我在使用 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; ?>
Run Code Online (Sandbox Code Playgroud)
那里的语法错误:
<?php if( $video_banner ); ?>
Run Code Online (Sandbox Code Playgroud)
替换为
<?php if( $video_banner ): ?>
Run Code Online (Sandbox Code Playgroud)
;在 if 的条件之后写 a就像写
<?php
if( $video_banner )
{
; //Do nothing
}
?>
Run Code Online (Sandbox Code Playgroud)
这意味着你有一个endif;多余的