I suppose you could either :
- use the dot (
.
) for strings concatenation, and use a single echo
- or use several strings in a single
echo
, separated by commas ',
'
See the echo
manual page, for examples.
For the first solution :
echo 'a' . 'b' . 'c';
And, for the second :
echo 'd', 'e', 'f';
And the output will be :
abcdef
Another solution would be to use variable interpolation in double-quoted string :
$my_var = "test";
echo "this is a $my_var";
Which will get you :
this is a test
For instance, using a bit of both :
$job = 'my job';
$skills = 'my skills';
$url = 'google.com';
$pay = 3.14;
echo "<p>Job: <span>$job</span></p>"
. "<p>Skills: <span class=\"caps\">$skills</span></p>"
. "<p>Website: <a href=\"http://$url\" title=\"$url\">http://$url</a></p>"
. "<p>Pay:$pay</p>";
You'll get :
Job: my job
Skills: my skills
Website: http://google.com
Pay:3.14
But note that you'll have to escape the "
, which is not easy to do :-(
So, yet another solution, based on heredoc syntax :
echo <<<STR
<p>Job: <span>$job</span></p>
<p>Skills: <span class="caps">$skills</span></p>
<p>Website: <a href="http://$url" title="$url">http://$url</a></p>
<p>Pay:$pay</p>
STR;
Only one echo
, no string concatenation, no escaping -- what else could one ask for ?
;-)