PHP交替内容
我正在尝试制作一个模板,其中:PHP交替内容,php,html,if-statement,Php,Html,If Statement,我正在尝试制作一个模板,其中: if(no_feature == 1) { TEXT (displayed on the left side), IMAGE (displayed on the right side) } else { IMAGE (displayed on the left side), TEXT (displayed on the right side) } 以下是我目前的代码: <div class="post-content"> <
if(no_feature == 1) {
TEXT (displayed on the left side), IMAGE (displayed on the right side)
} else {
IMAGE (displayed on the left side), TEXT (displayed on the right side)
}
以下是我目前的代码:
<div class="post-content">
<?php if ($this->get_field('no_feature')== 1);?>
<div class="one_half">
<?php echo "TEXT";?>
</div>
<div class="one_half last">
<?php echo "Image";?>
</div>
<?php else:?>
<div class="one_half">
<?php echo "Image";?>
</div>
<div class="one_half last">
<?php echo "Text";?>
</div>
<?php endif; ?>
</div>
您可以使用以下代码:
<div class="post-content">
<?php if ($this->get_field('no_feature')== 1): ?>
<div class="one_half">
<?php echo "TEXT";?>
</div>
<div class="one_half last">
<?php echo "Image";?>
</div>
<?php else: ?>
<div class="one_half">
<?php echo "Image";?>
</div>
<div class="one_half last">
<?php echo "Text";?>
</div>
<?php endif; ?>
</div>
在if条件下,半列应该是:标记。通常最好不要在HTML-DOM树中实现变量之类的内容。而是创建一个干净的列表,并使用样式类(在本例中使用浮点规则)处理可视化。通过这种方式,您可以将内容从可视化中分离出来,这意味着:您可以在以后更改可视化,而无需每次都重新编程 你的问题是什么?你的
if()
子句是空的。这是你的问题吗?我如何创建一个模板,用户输入-无功能,然后它将读取是否打印左/右图像。