Home  >  Article  >  Backend Development  >  Detailed introduction to EOF in php (code example)

Detailed introduction to EOF in php (code example)

不言
不言forward
2019-03-01 11:55:353097browse

This article brings you a detailed introduction (code example) about EOF in php. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. help.

php EOF (heredoc) is a method of defining a string in command line shells and programming languages. The method used is:

  • must be followed by points number, otherwise the compilation will not pass

  • EOF can be replaced by any other character, just ensure that the end identifier is consistent with the start identifier

  • The end tag must occupy a line by itself at the top of the line (that is, it must start from the beginning of the line, and no spaces or characters can be connected before and after)

  • The start tag can be without quotation marks or with single and double quotation marks. Without quotes and with double quotes, the effect is the same. Both interpret embedded variables and escape symbols. With single quotes, embedded variables and escape symbols are not interpreted.

  • When a single woolen item needs to have embedded quotes (single quotes or double quotes), there is no need to add an escape character. The single and double quotes will be escaped by itself.
    Detailed introduction to EOF in php (code example)
    == Note==

  • Start with

  • The start tag and the end tag must be the same, such as commonly used uppercase EOT, EOD, EOF. Express, but not just salted fish, as long as the start tag and end tag are consistent and do not appear in the text

  • The variables located between the start tag and the end tag can be normal Parsing, but the == function cannot == In heredoc, variables do not need to be spliced ​​with connectors. or, as shown in the figure
    Detailed introduction to EOF in php (code example)
    heredoc is often used when outputting documents containing a large number of HTML syntax
    Detailed introduction to EOF in php (code example)
    heredoc can be used to output large sections of html and JavaScript scripts

  • The function of the PHP delimiter is to output it as it is, including newline format and so on. Internal stuff;

  • Any special characters in PHP delimiters do not need to be escaped;

  • in PHP delimiters PHP variables will be replaced with their values ​​normally.

The above is the detailed content of Detailed introduction to EOF in php (code example). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete