嗨,有人可以向我解释,如果我之前有一个“if”状态,为什么我会遇到意外的其他事情?
PHP
<?php if($post_image=="") echo "There is no image" else echo '<img src="../img/'.$post_image.'">' ?>
答案 0 :(得分:3)
您需要使用分号终止语句:
<?php if($post_image=="") echo "There is no image"; else echo '<img src="../img/'.$post_image.'">'; ?>
答案 1 :(得分:1)
你错过了半冒号。你有:
<?php if($post_image=="") echo "There is no image" else echo '<img src="../img/'.$post_image.'">' ?>
^---- here and here ---^
您的需求:
<?php if($post_image=="") echo "There is no image"; else echo '<img src="../img/'.$post_image.'">'; ?>