Here document

A here-string, also here document (of English, literally here document ) called, is a linguistic concept of computer science for the specification of a string literal in command line interpreters such as bash, Windows PowerShell and the Bourne shell as well as in programming languages ​​such as Perl, PHP, Python, and Ruby. In keeping with the name heredocs serve to define blocks of text. In contrast to conventional string definitions contained newlines and indents, and many special characters are preserved in the text. Some languages ​​also allow the interpolation of variables or program code within the string.

Most heredocs be <<< followed by an arbitrary delimiter identifier ( separator), is introduced; in the subsequent row follows the text to be assigned. The end of the here-string is marked by a line containing the identifier and possibly a final semicolon previously selected.

Many UNIX shells, including the Bourne shell (sh), and zsh, offer heredocs as a way to specify input values ​​for command line commands.

Exemplary implementation in PHP:

see also

  • Literal
  • String
  • Programming language element
387984
de