Heredoc
A Heredoc , also called here document (from English , literally here document ), is a language concept in computer science for the specification of a character 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 . According to the designation, Heredocs are used to define sections of text. In contrast to conventional string definitions , contained line breaks, indents and many special characters are preserved in the text. Some languages also allow the interpolation of variables or program code within the character string.
Depending on the programming language heredocs be <<
, <<<
, <!--
, <<-
or similar strings initiated, followed by an arbitrary delimiter specifiers (separator); the text to be assigned follows in the following lines. The end of the Heredoc is marked by a line with the previously selected identifier and, if necessary, a terminating semicolon.
Many UNIX shells, including the Bourne shell (sh) and zsh, offer Heredocs as a way of specifying input values for command line commands. The Microsoft PowerShell provides similar functionality, both interactively in the shell itself, as well as a special script syntax script files that are executable in PowerShell.
Exemplary implementation in PHP :
<?php
echo <<<ENDE
Dies ist ein Heredoc
zweite Zeile
ENDE;
?>