Forums

Unexpected T_IF (3 posts)

  1. thisisedie
    Member
    Posted 1 year ago #

    Hiya. I'm using this to get my last comments. I'm trying to add a bit of code so there will only be a "..." after the comment body if the comment isn't shown in its entirety. This is what I'm using:

    ". if ($comment->com_excerpt >85) { echo "..."; } else { echo ""; } ."

    which returns "unexpected T_IF". I'm no PHP expert, just learning all this stuff, but I assume this means it doesn't like the if? Any ideas how to make this work?

    Thanks.

  2. elfin
    Moderator
    Posted 1 year ago #

    Does this work?

    $output .= "\n<li>".strip_tags($comment->comment_author)
    .":" . "<a href=\"" . get_permalink($comment->ID) .
    "#comment-" . $comment->comment_ID . "\" title=\"on " .
    $comment->post_title . "\">" . strip_tags($comment->com_excerpt);
    if ($comment->com_excerpt >85) {$output .= "..."; };
    $output .="</a></li>";
  3. thisisedie
    Member
    Posted 1 year ago #

    Nope, it didn't work but thank you. get the same error. It really doesn't seem to like the "if". Sigh.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.