Search code examples
phpstring-concatenation

How to concatenate strings with function calls while using echo?


I want to use the values returned from two function calls in my echo'ed html string.

<li><a href="the_permalink()">the_title()</a></li>

The following works fine:

echo '<li><a href="';
echo the_permalink();
echo '">';
echo the_title();
echo '</a></li>';

... but how do I get them all in one single statement?


Solution

  • echo '<li><a href="', the_permalink(), '">', the_title(), '</a></li>';