Leilin Peng Share: PHP EOF (heredoc) Instructions

  PHP EOF (heredoc) is a definition of a string on the command line shell (such as sh, csh, ksh, bash, PowerShell and zsh) and programming language (like Perl, PHP, Python and Ruby) in the method.

  Overview:

  1. must be followed by a semicolon, otherwise the compiler pass.

  2. EOF can be used in place of any other character, just to ensure consistent identity ends with the start of identity.

  3. End the logo must top grid alone accounted for one line (which must start from the beginning of the line, before and after can not link any gaps and characters).

  4. Start identification band or may not be single or double quotation marks marks, without quotation marks consistent results with quotation marks, embedded variables and interpretation escape character, single quotes embedded variables and escape symbol is not explained.

  5. When content needs embedded quotes (single or double), does not need an escape character, single and double quotation marks itself escaped, and where a considerable usage of q and qq.

  

  echo <<<eof< p="">

  

My first title

 

  

My first paragraph.

 

  EOF;

  // end requires a separate line and not a space before and after

  ?>

  note:

  1. <<

  2. The same start and end tags, such as the common capital of EOT, EOD, EOF to indicate, but not limited to those few (you can also use: JSON, HTML, etc.) that occur as long as the start and end tags are not the body can.

  3. Variables located between the start and end tags can be properly resolved, but the function can not. In heredoc, the variables do not need or connector to splice, as follows:

  

  $name="codercto";

  $a= <<<eof< p="">

  "abc"$name

  "123"

  EOF;

  // end requires a separate line and not a space before and after

  echo $ a;

  ?>

  View all PHP tutorial article: https://www.codercto.com/courses/l/5.html (edit: Leilin Peng Source: network intrusion deleted)

Guess you like

Origin www.cnblogs.com/linpeng1/p/10967820.html