我有一个 foreach 循环,它遍历注释,如下所示:
<?php
$comments = get_comments(array("status"=>"approve"));
foreach ( $comments as $comment ) { ?>
<div class="comment">
<h2><? echo get_comment_meta( $comment->comment_ID, "subject", $single = true ); ?></h2>
<p class="message"><?=$comment->comment_content;?></p>
</div>
<? } ?>
当我在实时服务器上运行它时,我收到以下错误:Parse error: syntax error, unexpected end of file in D:\UniServer\www\apps\app_name\wp-content\themes\sube\page-feedback.php on line 53
当我在本地运行站点时不会发生这种情况。所以我认为它是服务器配置错误。
此外,当我更改代码以使其回显内容时,它可以正常工作。例如:
<?php
$comments = get_comments(array("status"=>"approve"));
foreach ( $comments as $comment ) {
echo '<div class="comment">
<h2>'; get_comment_meta( $comment->comment_ID, "subject", $single = true ); echo'</h2>
<p class="message">'.$comment->comment_content.'</p>
</div>';
} ?>