如果在 if 内


if within an if

im 在将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 } ?>

这是你的问题:

if ($steptwocontent); {

将其更改为

if ($steptwocontent) {

编辑:

刚刚注意到你也对Stepthree内容做了同样的事情

改变

if ($stepthreecontent); {

if ($stepthreecontent) {