The end identifier must start in the first column of the row. Likewise, identifiers must follow the naming rules of any other tag in PHP: they must only contain alphanumeric underscores, and they must start with an underscore or a non-numeric character.
Warning
It is important to point out that the line that ends the identifier must not contain any other characters, except perhaps a semicolon (;). This means in particular that the identifier cannot be indented and there cannot be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline character as defined in your operating system. For example, on Macintosh systems it is r.
If you break this rule so that the end identifier is not "clean", it will not be treated as an end identifier and PHP will keep looking for it. Failure to find a suitable closing identifier in this case will result in a syntax error on the last line of the script.
Class members cannot be initialized using delimiter syntax. Use other string syntax instead. Example 11-3. Illegal example
PHP code
class foo {
public $bar = <<
EOT;
}
?>
Delimited text behaves like a double-quoted string, but without the double quotes. This means that quotes do not need to be escaped within delimited text, but the escape codes listed above can still be used. Variables are expanded, but the same care needs to be taken when expressing complex variables in delimited literals as with strings. Example 11-4. Delimiter string example
PHP code
$str = <<
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 <<
Now, I am printing some {$foo->bar[1]}.
This should print a capital 'A': x41
EOT;
?>
Note: Delimiter support was added in PHP 4.
How to output html code (EOT) in php
PHP code
echo <<< EOT
ClassID stuno Student's name Parent name Parent mobile number
EOT;
?>