Perl qq~~ and q~~ ability -> PHP?
Posted: Wed Apr 16, 2003 9:48 am
Perl has the ability to 'inline' HereDocs by using qq~~ (double quoting) and q~~ (single quoting) a portion of text exactly like a HereDoc does (parsing $vars while keeping nopn-escaped "s and 's as well) without taking up entire lines for start and end tags. Also the ~ symbol can be replaced by any character that you wont be using within the string, and if you do, can be escaped to still print it out. It also allows for multiple HereDoc conversions on a single line, examples as follows:
can be done as follows:
which allows more condensed code and, atleast i think, makes creating formatted HTML easier.
Code: Select all
echo <<< END_HERE1
remembers "quotes" and parses $vars
and 'remembers' new lines
END_HERE1;
echo join("\n", $array_list);
echo <<< END_HERE2
and continues.
END_HERE2;Code: Select all
echo qq~... "quotes" and $vars\n~ . join("\n", $array_list) . qq~and ...\n~;