gpt4 book ai didi

php - 使用单引号时在 PHP 中创建制表符和换行符的正确方法是什么?

转载 作者:行者123 更新时间:2023-12-02 01:21:23 24 4
gpt4 key购买 nike

似乎是一个简单的问题,但我无法在任何地方找到可靠的答案。我输出了大量的 HTML,发现转义的 "很容易出错并且难以阅读,但我也希望我的 HTML 格式良好。

想要这样的东西(虽然我知道这行不通):

echo '<div id="test">\n';
echo '\t<div id="test-sub">\n';
echo '\t</div>\n';
echo '</div>\n';

一个人该做什么?

谢谢。

最佳答案

你看过HEREDOC吗?

Heredoc text behaves just like adouble-quoted string, without thedouble quotes. This means that quotesin a heredoc do not need to be escaped

这里的优势示例:http://www.shat.net/php/notes/heredoc.php

关于php - 使用单引号时在 PHP 中创建制表符和换行符的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3960307/

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