The end identifier must start at the first column of the row. Similarly, identifiers must follow the naming conventions of any other tag in PHP: They can only contain alphanumeric underscores, and must begin with an underscore or non-numeric character.
Warning
It is important to note that the line where the end identifier is located cannot contain any other characters, except for a semicolon (;). This in particular means that the identifier cannot be indented and cannot have any spaces or tabs before and 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, in the Macintosh system is \ r.
If you break this rule so that the end identifier is not "clean", it will not be considered a closing identifier, and PHP continues to look for it. If the appropriate end identifier is not found in this case, it will result in a syntax error that appears in the last line of the script.
Class members cannot be initialized with delimiter syntax. Replace with other string syntax. Example 11-3. Examples of illegal
PHP code
class Foo {
Public $bar = << Bar
EOT;
}
?>
The delimiter text behaves just like a double-quoted string, with no double quotes. This means that you do not need to escape quotes in the delimiter text, but you can still use the escaped code listed above. Variables are expanded, but when you express complex variables in the delimiter text, you should be aware of the same as the string. Example 11-4. Delimiter String Example
PHP code
$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 should print a capital ' a ': \x41
EOT;
?>
Note: The delimiter support is added in PHP 4.
How to output HTML code in PHP (EOT)
PHP code
Echo <<< EOT
http://www.bkjia.com/PHPjc/319515.html www.bkjia.com true http://www.bkjia.com/PHPjc/319515.html techarticle the end identifier must start at the first column of the row. Similarly, identifiers must follow the naming conventions of any other tag in PHP: They can only contain alphanumeric underscores, and must be underlined ...
ClassID |
Stuno |
Student Name |
Parent's name |
Parent Mobile Number |
EOT;?>