In fact, the application of delimiters in php is quite good. for example, the famous Phpwind uses the delimiters. I also used it when working on projects. I feel that I can use it to basically separate code from pages. However, you have to be very careful and it is easy to make mistakes. The following is an article on a network that describes how to use the delimiters and what you should pay attention. Another method to define the string using the delimiter syntax (& ldquo; & lt; in fact, it is quite good to use the delimiter in php, for example, the famous Phpwind uses the delimiter. I also used it when working on projects. I feel that I can use it to basically separate code from pages. However, you have to be very careful and it is easy to make mistakes. The following is an article on a network that describes how to use the delimiters and what you should pay attention.
DelimitersAnother method is to define the string using the delimiter syntax ("<"). An identifier should be provided after <, followed by a string, followed by the end string of the same identifier.
The end identifier must start from the first column of the row. Similarly, the identifier must follow the naming rules for any other tag in PHP: it can only contain letters, numbers, underscores (_), and must start with an underscore or a non-digit character.
Warning
It is important to note that the row of the end identifier cannot contain any other character, except a semicolon. This especially means that the identifier cannot be indented, and there cannot be any spaces or tabs before or after the semicolon. It is also important to realize that the first character before the end identifier must be a line break defined in your operating system. For example, \ r is used in a Macintosh system.
If this rule is broken so that the end identifier is not "clean", it will not be regarded as the end identifier, and PHP will continue searching for it. If an end identifier cannot be found in this case, a syntax error occurs in the last line of the script.
Class members cannot be initialized using the delimiter syntax. Use other string syntax instead. Example 11-3. invalid example
Class foo {
Public $ bar = < Bar
EOT;
}
?> The delimiter text is the same as the double quotation mark string, but it does not contain double quotation marks. This means that no escape quotation marks are required in the delimiter text, but the escape code listed above can still be used. The variable is expanded, but when the complex variable is expressed in the delimiter text, you should also note the same as the string. Example 11-4. delimiter string example
$ Str = < Example of string
Spanning multiple lines
Using heredoc syntax.
EOT;
/* More complex example, with variables .*/
Class foo
{
Var $ foo;
Var $ bar;
Function foo ()
{
$ This-> foo = 'foo ';
$ This-> bar = array ('bar1', 'bar2', 'bar3 ');
}
}
$ Foo = new foo ();
$ Name = 'myname ';
Echo < My name is "$ name". I am printing some $ foo-> foo.
Now, I am printing some {$ foo-> bar [1]}.
This shoshould print a capital 'A': \ x41
EOT;
?>
Note: The delimiters can be added to PHP 4.
How to output html code (EOT) in php) Echo <EOT
Student Name
Summary? The separator "<" is followed by the demarcation identifier. An identifier consists of letters, numbers, or underscores and cannot start with a number. The end identifier must be fixed and cannot contain any other character. The common error is to indent the end of the demarcation identifier. Variables in the delimiters can be parsed. escape characters can be used, but no quotation marks are required. It is especially convenient to use delimiters when a large number of texts need to be defined or output.
Official Reference Manual: http://www.php.net/manual/zh/language.types.string.php
I was just reading a book? EOT, EOD? I thought there was a difference. I tried it and wrote it casually. Match the naming rules of identifiers. For example:
<.......
Abc
ClassID |
Stuno |
Parent name |
Parents' mobile phone number |
EOT;?>