Home > Backend Development > PHP Tutorial > Detailed explanation of the use of PHP EOT delimiter_PHP tutorial

Detailed explanation of the use of PHP EOT delimiter_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:49:28
Original
1043 people have browsed it

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 = <<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 = <<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: Delimiter support was added in PHP 4.
How to output html code (EOT) in php
PHP code
echo <<< EOT








EOT;
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319515.htmlTechArticleThe end identifier must start from the first column of the row. Likewise, identifiers must follow the naming rules for any other tag in PHP: they can only contain alphanumeric underscores, and they must begin with an underscore...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
ClassIDstuno Student's name Parent name Parent mobile number