I have a foreach loop that iterates through comments as such:
<?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>
<? } ?>
When I run it on a live server, I get the following error: 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
This doesn’t happen when I run the site locally.. so I’m thinking its a server configuration error.
Also, when I change the code so that it echo’s the content, it works fine. For example:
<?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>';
} ?>
Your live server may not have the
asp_tagsphp.ini directive set. According to the docs, this is what enables the variable-value printing shorthand. You will also want to make sureshort_open_tagis enabled too.