Hello! Met in the code is such a function. Why is it needed and what functions in the code it performs. I searched on the Internet, but found nothing, except discussion forums. Who is not difficult to describe in simple language or a link to the description. Thank.

  • Displays text - butteff 8:38 pm
  • Well, for something concrete, simple text and echo displays) - LordySL
  • print - displays a string. echo - displays one or more lines - Vitali RS

3 answers 3

This is the heredoc syntax

For what - so as not to bother with shielding, hyphenation within the lines and so on. For convenience, in short)

    I will give an example where you can use this function. Well, for example, in PHP code you wrote an if-else condition, like this:

    if(!isset(переменная)) { и сделай что нибудь; } else //и хотим, ну например здесь прикрепить HTML форму,тогда пишем! { print<<<HERE наша форма HERE; } 

    Only carefully, this is a capricious function, make sure that after print<<<HERE and HERE; there was not a single space, otherwise the function may not work.

      It is in the version

       print <<< HERE HERE; 

      "this feature" does not make sense. To display a large amount of text, simply close the PHP tag and continue to write what should be displayed. It will be more convenient, easier and more understandable.

      Use heredoc only makes sense if a large chunk of text needs to be stored in a variable.