I'm relatively new to php & was wondering if I can pass echo statement within variable. I have this in wordpress trying to retrieve profile picture using variable id to be able to integrate in wp comment section. Tried this.
$idd= author_details(get_the_ID());
$authordata = get_userdata( $idd );
$au=$authordata->display_name;
$authorAvatar = '<img src="http://www.example.com/photos/<?php echo getimg($au);?>" class="avatar user-1-avatar avatar-28 photo" width="40" height="40" alt="profile pic" >';
Here is the result image url I'm getting:
http://www.example.com/photos/%3C?php%20echo%20getimg($au);?%3E
It's apparent that I cannot pass echo statement within variable, but the sad thing is I'm unable to find solution for this simple stuff.
Note: The code works perfectly when they are put outside variable.
Voluntary help will be highly appreciated. Thanks.