本文介绍了PHP表达式<<< EOB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用PHP开发了好几年了,最近碰到了这段代码:

 <?php 
echo<<< EOB
< html>
< head>
< title>我的标题< / title>
< / head>
...
EOB;
?>

我从来没有见过这种打印HTML的方法,这看起来很有用,也不太容易一些奇怪的变量或双引号语法错误。



我搜索了一些有关这方面的官方信息,只发现了一篇关于Rasmus的文章。 b
$ b

什么是关于这个功能的详细解释和EOB是什么意思?也许结束块

解决方案

这就是所谓的语法。该文件将告诉你所有你需要知道的事情。



实际上,不过:

所以 EOB 就是作者选择的分隔符,而不是真的确定它在他的情况下代表什么,但标识符可以是任何你想要的。


I've been developing with PHP for some years now, and recently came across this code:

<?php
    echo <<<EOB
        <html>
        <head>
            <title>My title</title>
        </head>
        ...
    EOB;
?>

I've never seen this approach to print HTML, which seems to be pretty useful and less prone to some weird variable or double quote syntax error.

I've searched for some official information about this and only found a post of Rasmus talking about this.

What is a detailed explanation about this functionality and what does EOB mean? Maybe end of block?

解决方案

This is known as heredoc syntax. The documentation will tell you everything you need to know.

Essentially, however:

So EOB is just what the author chose as his delimiter, not really sure what it stands for in his case but the identifier can be whatever you want.

这篇关于PHP表达式&lt;&lt;&lt; EOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 03:25