I am trying to learn to write more advanced strings. I know I could do this using three different statements, as such:
<?php
function1();
echo " | ";
function2();
?>
To get a result like this: result1 | result2
(my real world example for this is creating links to previous and next posts in wordpress, such as:
<?php
previous_post_link( '%link', '< Previous' );
echo ' | ';
next_post_link( '%link', 'Next >' );
?>
)
But, since I am trying to improve, and learn new things, I am trying to write this more cleanly. I know I can use double quotes and curly brackets to insert functions, like this:
<?php
echo "{${function1()}} | {${function2()}}";
?>
But this returns a result like this: result1result2 |
Why does this happen and how can i write this code correctly?
Thanks!