Treehouse: Grow your CSS skills. Land your dream job.

Wrap $ in Tag?

  • # June 22, 2011 at 12:56 pm

    Anyone know how I’d wrap $likes in a span tag? If it’s even possible.

    $likes = likeThis($post_id);

    Sorry if I make no sense at all, I’m still trying to wrap my head around PHP.

    Thanks in advance.

    # June 22, 2011 at 3:47 pm
    echo '' . $likes . '';

    No question is too basic when you’re just starting out

    # June 22, 2011 at 4:58 pm

    By the way, what @TT_Mark did there is called concatenation. You can concatenate a string, such as “Hello World” to a variable or another string using a period/full stop, and you can do it as many times as you want.

    # June 22, 2011 at 6:23 pm

    @TT_Mark Thanks for the help guys. That’s why I love this forum.

    I’m trying to modify a plugin called Like This.

    My PHP looks like this at the moment.

    function printLikes($post_id) {
    $likes = likeThis($post_id);

    $who = 'Love it? ';

    if(isset($_COOKIE["like_" . $post_id])) {
    print ''.$who. ''.$likes.' loves';
    } //if
    print ''.$who. ''. $likes.' loves';
    } //printLikes

    I’ve wrapped both $likes in a span tag. The span tag is present before I like the item, but when I “like” the item the span tag disappears, this is the one with the “done” class.

    Hope that makes sense, thanks.

    # June 23, 2011 at 2:53 am

    Seems it been changed by the js.

    At the end of function reloadLikes(who)

    $j("#" + who).text(text);

    That might be the problem.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.