-2

if我在将语句放在语句中时遇到了一个小问题,if例如:

<?php
$steponeimage = get_post_meta($post->ID, 'step_one_image', true);
$steponecontent = get_post_meta($post->ID, 'step_one_content', true);
$steptwoimage = get_post_meta($post->ID, 'step_two_image', true);
$steptwocontent = get_post_meta($post->ID, 'step_two_content', true);
$stepthreeimage = get_post_meta($post->ID, 'step_three_image', true);
$stepthreecontent = get_post_meta($post->ID, 'step_3_content', true);
if ($steponecontent) {
?>
<div id="processPanel" class="panel">
    <a href="#content1" label="1">Step 1</a>
<?php if ($steptwocontent) { ?>
<a href="#content2" label="2">Step Two</a>
<?php } else { ?><?php } ?>
<?php if ($stepthreecontent) { ?>
<a href="#content3" label="3">Step Three</a>
<?php } else { ?><?php } ?>
    <div id="content1">
<p><?php $images1 = $helper->imageDisplay($steponeimage , $height , $width , true , $ar[0] , false, false,'' ,'' ,false);
echo "<div class='imageholder'> $images1 </div>"; ?></p>
<p><?php echo $steponecontent; ?></p>
</div>
<?php if ($steptwocontent); { ?>
<div id="content2">
<p><?php $images2 = $helper->imageDisplay($steptwoimage , $height , $width , true , $ar[0] , false, false,'' ,'' ,false);
echo "<div class='imageholder'> $images2 </div>"; ?></p>
<p><?php echo $steptwocontent; ?></p>
</div><?php } else { ?><?php } ?>
<?php if ($stepthreecontent); { ?>
<div id="content3">
<p><?php $images3 = $helper->imageDisplay($stepthreeimage , $height , $width , true , $ar[0] , false, false,'' ,'' ,false);
echo "<div class='imageholder'> $images3 </div>"; ?></p>
<p><?php echo $stepthreecontent; ?></p>
</div><?php } else { ?><?php } ?>
</div>
<?php } else { ?>
<?php } ?>

我正在尝试从 wordpress 帖子中读取帖子元数据,如果填写了第一步元框,它会显示分步信息,然后如果填写了第二步的元框,则在此处添加第二步,如果第三步的框是填充它添加第三步等。

我的错误是

解析错误:语法错误,意外的 T_ELSE

这来自这里:

<p><?php echo $steptwocontent; ?></p>
</div><?php } else { ?><?php } ?>
4

1 回答 1

3

这是你的问题:

if ($steptwocontent); {

将其更改为

if ($steptwocontent) {

编辑:

只是注意到你也对 stepthreecontent 做了同样的事情

改变

if ($stepthreecontent); {

if ($stepthreecontent) {
于 2012-05-19T11:24:42.727 回答