gpt4 book ai didi

相当于 python 的三引号的 PHP - 如何在不转义的情况下在 PHP 中打印大量/大量的 HTML

转载 作者:太空狗 更新时间:2023-10-29 20:54:29 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
php string escaping like python’s “”“ ”“”?

python 中的三重引号转义了其中包含的所有引号和换行符。例如,

""" this
is all


just one string. I can even tell you "I like pi".
Notice that the single quotes are escaped - they don't end the string; and the newlines become part of the string
"""

有谁知道 PHP 是否有 python 的等价物

""" <form><h1>PUT HTML HERE</h1> </form> """
enter code here

编辑:对于那些以后看这个问题的人,我已经回答了,这里是一个例子:

$heading = "Heading Gettizburgz";
print <<< END
<p><h1>$heading</h1> "in quotes" 'in single'
Four score and seven years ago<br/>
our fathers set onto this continent<br/>
(and so on ...)<br/>
</p>
END;

打印:
Heading Gettizburgz
"in quotes" 'in single' Four score and seven years ago
our fathers set onto this continent
(and so on ...)

注意一件重要的事情,你必须确保最后一个 END位于代码的最左侧(第一列),前面没有任何空格。

来源:http://alvinalexander.com/blog/post/php/php-here-document-heredoc-syntax-examples

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com