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
PHP code
<? Php
Class foo {
Public $ bar = <EOT
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
PHP code
<? Php
$ Str = <EOT
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 <EOT
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)
PHP code
<? Php
Echo <EOT
<Table width = 80% border = "2" cellpadding = "3" cellspacing = "0" bordercolor = "#808080">
<Tr bgcolor = "#84A9E1">
<Td align = "center"> ClassID </td>
<Td align = "center"> stuno </td>
<Td align = "center"> Student name </td>
<Td align = "center"> parent name </td>
<Td align = "center"> parents' mobile phone number </td>
</Tr>
EOT;
?>