The first one uses HEREDOC
syntax. It's useful when you're working with multi-line strings and to avoid quoting problems. To solve the search issue, you can use a programming search engine that doesn't ignore special characters (like SymbolHound).
What is the difference between "<<<SQL SQL;" and using quotes for a statement [duplicate]
Pregunta
Could anyone provide some sort of documentation on the differences and or benefits of using
$sql = <<<SQL
SELECT COUNT(ParentGUID)
FROM siteobjects
SQL;
Instead of using just using.
$sql = "SELECT COUNT(ParentGUID)
FROM siteobjects";
Struggling to find any information on this due to searching for "<<
Solución
Otros consejos
There's no difference except for the fact that the HEREDOC would have white spaces in the start (because of tabulation).
That's PHP Heredocs syntax (http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc). I prefer heredocs over simple strings because almost any IDE recognize the syntax, and it's more readable, but both options are possible.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow