Also, watch out for heredoc closing identifiers.
Invalid Example:
// it's not working!!!
function findAll() {
$query=<<<SQL
SELECT * FROM `table_1`;
SQL; // <-------- THIS IS BAD
// ...
}
This will throw an exception that resembles the following:
<br />
<b>Parse error</b>: syntax error, unexpected end of file in <b>[...][...]</b> on line <b>5</b><br />
where number 5 might be the last line number of your file.
According to php manual:
Warning
It is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is \n on UNIX systems, including macOS. The closing delimiter must also be followed by a newline.
TLDR: Closing identifiers should NOT be indented.
Valid Example:
function findAll() {
$query=<<<SQL
SELECT * FROM `table_1`;
SQL;
// closing identifier should not be indented, although it might look ugly
// ...
}
short_tags
in your php.ini under BOTHapache
andcli
configs – AO_