I like the HEREDOC syntax, e.g. for edge cases of generated HTML that are not worth putting into a template.
The only thing that annoys me about it, though, is that the content, and the closing marker of a heredoc string adheres to the first column. This screws up nested code layouts:
class myclass
{
function __construct()
{
$a = some_code();
$b = some_more_code();
$x = <<<EOT
line1
line2
line3
line4
EOT;
$c = even_more_code();
$b = still_more_code();
...
...
...
you see what I mean.
Now this is probably not solvable using normal HEREDOC. Has anybody worked around this? My dream would be to have HEREDOC syntax with automatic indentation. But I guess this is not possible without writing some pre-compiler for the source files.
Am I correct?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…