Re: Using a heredoc in PHP as in Perl [message #171887 is a reply to message #171885] |
Thu, 20 January 2011 09:16 |
Luuk
Messages: 329 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 20-01-11 10:00, P E Schoen wrote:
> 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
>
>
The best syntax of a heredoc in PHP is found on the site with the docs
http://www.php.net
for 'heredoc' this is:
http://nl3.php.net/manual/en/language.types.string.php#language.types.strin g.syntax.heredoc
--
Luuk
|
|
|