PHP Function Call within a PHP

Discussion in 'PHP' started by Abhik, Aug 22, 2011.

  1. #1
    Hello,
    I was trying my luck at coding a small WordPress plugin.. But, I am stuck at a point.

    How can I do this?

    <?php
    
    function myfunc($content) {
    
    $content.= '<span style="margin-top:10px" class="avatar"><?php echo get_avatar(get_the_author_email(), 70);?></span>';
    
    return $content;
    }
    add_filter ('the_content', 'end_post');
    
    ?>
    PHP:
    When ever I put that, the <?php and ?> at the $content. automatically turns into <!--php and -->.
    How do I call that gravatar (or any function) there at the $content?
     
    Solved! View solution.
    Abhik, Aug 22, 2011 IP
  2. #2
    There is no need to parse php in php. The function can just be executed the fist time:
    
    function myfunc($content) {
    
    $content.= '<span style="margin-top:10px" class="avatar">'. get_avatar(get_the_author_email(), 70).'</span>';
    
    return $content;
    }
    
    PHP:
     
    ssmm987, Aug 22, 2011 IP
  3. Abhik

    Abhik ..:: The ONE ::..

    Messages:
    11,337
    Likes Received:
    606
    Best Answers:
    0
    Trophy Points:
    410
    Digital Goods:
    2
    #3
    Awesome!!! :)
    Thanks
     
    Abhik, Aug 22, 2011 IP