2

What is the effect of the following code?

$page = <<<CON <p><center>Blah blah blah</center></p> CON; 

What does the <<<CON do?

2 Answers 2

7

This is known as heredoc. It's essentially a way of defining the value of a variable that spans multiple lines, and doesn't require escaping like traditional strings. The "CON" part is merely an identifier that represents the start and end of the value. This can be changed to a more familiar value.

$str = <<<EOD Example of string spanning multiple lines using heredoc syntax. EOD; 
Sign up to request clarification or add additional context in comments.

2 Comments

+1 Solid answer. One thing to note may be that the last line EOD; can not be indented afaik (making for some ugly code sometimes).
Correct, ChristopheD. Nothing before the last identifier, and nothing after (with the exception of the semi-colon).
2

That's the PHP heredoc operator. Details at this link:

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.