Using a heredoc in PHP as in Perl [message #171885] |
Thu, 20 January 2011 09:00 |
P E Schoen
Messages: 86 Registered: January 2011
Karma:
|
Member |
|
|
I am going to be using PHP to perform an HTML purification before the user's
input from a form is presented to a Perl script which saves the content and
presents it in HTML format. I am totally new to PHP and I have just a basic
working knowledge of Perl. In Perl, I use a heredoc which is done with a
statement such as:
print <<"END";
My Text...
END
I found several references such as http://en.wikipedia.org/wiki/Heredoc to a
similar means for PHP, but it did not work for me (parse error on line with
the <<<):
echo <<<EOF
My Text...
EOF;
I am actually using this to create HTML, and I found that it can be simply
written in the PHP document outside the <?php and ?> tags. But I would also
like to be able to use a heredoc to print to a file, and I don't know if
that is possible in PHP. If so, I'd appreciate any ideas on how to do it.
TIA.
Paul
|
|
|