Home >
Article > Backend Development > Analysis of PHP's delimiter <<
php delimiter <<
PHP is a Web programming language. During the programming process, you will inevitably encounter the situation of using echo to output large sections of html and javascript scripts. If you use the traditional output method-output by string, you must have a large number of escape characters to match the quotation marks in the string. Escape special characters to avoid syntax errors. If it is one or two places, it can be tolerated, but if it is a complete html text or a 200-line js, I think everyone will collapse. This is why PHP introduces a delimiter - at least a large part of the reason.
1. The function of the PHP delimiter is to output what is inside it as it is, including newline format and so on;
2. Any special characters in the PHP delimiter are No escaping is required;
3. PHP variables in the PHP delimiter will be replaced with their values normally.
The delimiter format in PHP is like this:
<< …… EOF;
Such as:
<?php $js = <<<EOF <script type="text/javascript"> //top:作用使得整个frameset都跳转 window.top.location.href = "$group_url/Manager/login"; </script> EOF; return $js;
Recommended tutorial: "php from entry to proficiency"
The above is the detailed content of Analysis of PHP's delimiter <<