Bash: warning: here-document at line delimited by end-of-file (wanted `EOF’) [duplicate]
You have a space after the final EOF hence it was unable to terminate the heredoc. p/s: Noticed this while copy-pasting your code.
You have a space after the final EOF hence it was unable to terminate the heredoc. p/s: Noticed this while copy-pasting your code.
PHP was itself originally intended as a templating language (ie a simple method of allowing you to embed code inside HTML). As you see from your own examples, it got too complicated to justify being used in this way most of the time, so good practice moved away from that to using it more as … Read more
In the pipeline, two new processes are created: one for a shell to execute the echo command, and one for a shell to execute the read command. Since both subshells exit after they complete, the x variable is not available after the pipeline completes. (In bash 4, the lastpipe option was introduced to allow the … Read more
Try ES6 String Template, you can do something like var hereDoc = ` This is a Multiple Line String `.trim() hereDoc == ‘This\nis\na\nMultiple\nLine\nString’ => true You can use this great feature even in older browsers with TypeScript
You have a whole bunch of spaces (9 to be exact) after the EOT; in the loop. From the manual … there may not be any spaces or tabs before or after the semicolon … Why are you wrapping the $output variable inside a HEREDOC string? I’d just change the loop to printf(‘<tr><td align=”left”>%s</td><td align=”left”>%s</td></tr>’, … Read more
(If you are using bash 4, scroll to the end for what I think is the best combination of pure shell and readability.) For heredocs, using tabs is not a matter of preference or style; it’s how the language is defined. usage () { ⟶# Lines between EOF are each indented with the same number … Read more
Use printf %q to escape content in an eval-safe form; after doing so, you can pass them on the command line of the remote shell, and retrieve them via $1, $2, etc. within the remote script: # put contents of $VAR into $var_str in a format that a shell can interpret printf -v var_str %q … Read more
Thank goodness this feature has finally landed in php 7.3 via RFC: Flexible Heredoc and Nowdoc Syntaxes So now your example can cleanly be written as: 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(); } }
Your heredoc needs a little modification (because it’s actually Nowdoc!): echo <<<EX <p>Game: {$data[‘game_name’]}<br/> the owner of the game is {$data[‘game_owner’]} </p> EX; Heredoc identifiers (unlike nowdoc ones) cannot be quoted. ‘EX’ needs to become EX. You’re confusing Nowdoc with heredoc. Complex data types in strings must be surrounded by {} for them to be … Read more
Quote the delimiter: cat <<-“EOF” > somefile.sh Do not print current value of $1 instead evaluate it later. EOF This results in: $ cat somefile.sh Do not print current value of $1 instead evaluate it later. Documentation The format of here-documents is: <<[-]word here-document delimiter No parameter and variable expansion, command substitution, arithmetic expansion, or … Read more