Special use of this syntax in PHP? (Triple “angle brackets”)

Given the following code:

$myString = <<<script . . . script; 

Thanks to the answers to the original version of this question, I understand that <<<be the heredoc syntax, treated as double quotes without the need to speed up quotes.

Taking one more step, how is it best to use? In particular, should this make it easier to work with mixed quote strings containing code syntax?

e ..

 attribute="name-like string" attribute="property: 'value("value")';" 

The idea that this can be useful (if it is implemented as I guess now), especially when it comes to greater complexity and / or in search of code injection. Again, search for any scenarios where heredoc for is especially useful or useful.

+8
string css php heredoc brackets
source share
3 answers

This is the Heredoc syntax: http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Its greatest virtue is that you don't have to worry about escaping quotes, as the string is not limited to quotation.

+9
source share

It is called the heredoc syntax:

The third way to distinguish between strings is the heredoc syntax: <<After this statement, an identifier is provided, and then a newline. This is followed by a line and then the same identifier to close the quote.

Read more here .

+2
source share

It acts like a string with two qouted, it is better to use double qoutes, easier to understand and simplify for my eyes!

+2
source share

All Articles