PHP: Using Proper Indentation with Heredocs [duplicate] PHP: Using Proper Indentation with Heredocs [duplicate] php php

PHP: Using Proper Indentation with Heredocs [duplicate]


It's a limitation of PHP to properly format Heredoc statements. It's a parser limitation. As the documentation states:

It is very important to note that theline with the closing identifier mustcontain no other characters, exceptpossibly a semicolon (;). That meansespecially that the identifier may notbe indented, and there may not be anyspaces or tabs before or after thesemicolon. It's also important torealize that the first characterbefore the closing identifier must bea newline as defined by the localoperating system. This is \n on UNIXsystems, including Mac OS X. Theclosing delimiter (possibly followedby a semicolon) must also be followedby a newline.

If this rule is brokenand the closing identifier is not"clean", it will not be considered aclosing identifier, and PHP willcontinue looking for one. If a properclosing identifier is not found beforethe end of the current file, a parseerror will result at the last line.

It's unknown if this is gonna be resolved in the future of PHP.


AFAIK, that's not possible, you need to put closing heredoc identifier without any spaces/tabs/indentation :(