-2

我编写了以下 PHP 语句,但每次我尝试将它组合到 else/if 中时,它都会中断。

有人可以建议吗?我是 PHP 新手,有点卡住了。

谢谢 :)

<?php if (is_page( 19 ) ) {?>
<div class="imageSlider"><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image2.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image3.jpg" alt="" /></div>
<?php }?>

<?php if (is_page( 23 ) ) {?>
<div class="imageSlider"><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /></div>
}
<?php }?>
4

3 回答 3

3

使用此语法:

<?php if (condtion):?> 
 // html goes here,
<?php elseif(condtion): ?>
 // html goes here,
<?php endif; ?>
于 2012-07-04T15:17:42.577 回答
0

这是使用您的代码的 if/else 示例

<?php if (is_page(19)) { ?>
    //Insert html
<? { elseif (is_page(23)) } ?>
   //Insert other html
<? } ?>
于 2012-07-04T15:12:31.680 回答
0
<?php if (is_page( 19 ) ) {?> 
<div class="imageSlider"><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image2.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image3.jpg" alt="" /></div> 
<?php } elseif (is_page( 23 ) ) {?> 
<div class="imageSlider"><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /><img src="<?php echo bloginfo('template_directory');?>/Images/mainImages/innerPage-Image.jpg" alt="" /></div>
<?php }?> 
于 2012-07-04T15:07:44.800 回答