What is the purpose of <<< in PHP

3 views
Skip to first unread message

babal

unread,
Aug 25, 2008, 12:42:05 AM8/25/08
to PHP Hacks
Hello Everyone,

I have saw in many script usage of "<<<" operator/function i m not
sure what should i call it.
Can anyone tell me what is the purpose of this, but it sounds very
interesting & powerful.

As i saw the code it allows to print JavaScript code which is written
in PHP.

i was googling it but haven't got anything.

Thanks

babal

phew72

unread,
Sep 1, 2008, 5:40:09 AM9/1/08
to PHP Hacks
The '<<<' refers to the HEREDOC method of echoing strings.

If you have a large, multi-lined block of text or code you want to
echo, instead of putting a echo " ... "; at the start of each line you
can wrap the whole lot in a code block that starts with <<<block
...
and ends with
...
block;

Have a google search under 'php heredoc', or
http://www.phpf1.com/tutorial/php-heredoc-syntax.html for more info.

fwd...@gmail.com

unread,
Aug 26, 2008, 7:24:07 AM8/26/08
to PHP Hacks
Hi Babal,

The here document syntax (operator <<<) is used to output multiple
lines with $variable interpolation. Note
that the here document terminator must appear on a line with just a
semicolon no extra whitespace!

Example:

print <<<END
This uses the "here document" syntax to output
multiple lines with $variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon no extra whitespace!
END;

For more information visit this :

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc



Regards,
Fahad Waheed Khan
Reply all
Reply to author
Forward
0 new messages