Use Heredoc for printing multiple lines echo <<<

by Geethalakshmi 2011-02-03 12:12:04

Use Heredoc for printing multiple lines echo <<<

Herodoc

An alternative to using quotes is to use heredoc syntax (<<<). Begin by writing the "<<<" followed by the terminator label (which can be any valid label, I used "te"). Then write the string and finally, on a new line write the terminator. The contents of the string are evaluated. For instance

echo <<<te //te is an arbitrary label

Just here we have

some text which can

be evaluated including $something

te; //finally repeat the label

//result: Just here we have some text which can be evaluated including Oh something!

Tagged in:

1201
like
0
dislike
0
mail
flag

You must LOGIN to add comments