The function getUserAvatar outputs the following :
<img src="http://pathtoimage/image.jpg" height="16" width="16" alt="avatar" />
I'm calling it within a particular div.
When I call it like this is works perfectly :
echo '<div class="avatar">';
echo getUserAvatar($avatar_id);
echo '</div>';
Resulting in the following html output :
<div class="avatar"><img src="http://pathtoimage/image.jpg" height="16" width="16" alt="avatar" /></div>
But when I try to put it all on one line :
echo '<div class="avatar">' .getUserAvatar($avatar_id). '</div>';
It results in the following html, executing the function before rendering the div tags? :
<img src="http://pathtoimage/image.jpg" height="16" width="16" alt="avatar" /><div class="avatar"></div>
Could somebody please explain why this is and offer the correct solution?
getUserAvatarfunction?returnthe string in yourgetUserAvatar.