[英]Php parse error, help me fix the mistake
該代碼有誤。 什么是正確的代碼?
<?php
$guide = get_post_meta($post->ID, '_wpb_in_onda', TRUE);
if($guide){
?>
<div>
<?php echo stripslashes(htmlspecialchars_decode($guide));?>
</div>
解析錯誤:語法錯誤,第7行的CODE中意外的$ end
您可以使用if:else:endif;
句法:
<?php
$guide = get_post_meta($post->ID, '_wpb_in_onda', TRUE);
if($guide):
?>
<div><?php echo stripslashes(htmlspecialchars_decode($guide));?></div>
<?php endif;?>
或您正在做什么,但是如果需要大括號}
則需要關閉:
<?php
$guide = get_post_meta($post->ID, '_wpb_in_onda', TRUE);
if($guide){
?>
<div><?php echo stripslashes(htmlspecialchars_decode($guide));?></div>
<?}; // this is missing in your code ?>
或者您也可以回顯HTML:
<?php
$guide = get_post_meta($post->ID, '_wpb_in_onda', TRUE);
if($guide){
echo '<div>' . stripslashes(htmlspecialchars_decode($guide)) . '</div>';
};
?>
您不會結束if標簽。 除此之外,對於某些HTML編碼來說,打破PHP並不是很干凈,您寧願在PHP中使用“ echo”命令。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.