douxi5940 2010-10-18 14:46
浏览 27
已采纳

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

Seems like a simple question, but I haven't been able to find a solid answer anywhere. I'm outputting a ton of HTML and find escaping "s to be error prone and hard to read, but I also want to have my HTML formatted nicely.

Want something like this (though I know this won't worK):

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

What is one to do?

Thanks.

  • 写回答

4条回答 默认 最新

  • douguan3470 2010-10-18 14:56
    关注

    did you look on HEREDOC

    Heredoc text behaves just like a double-quoted string, without the double quotes. This means that quotes in a heredoc do not need to be escaped

    example of advantage here : http://www.shat.net/php/notes/heredoc.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 c51单片机控制步进电机
  • ¥20 Visual studio无法检测到设备
  • ¥15 为什么我通过html绘制的SVG折线图插入到word中坐标轴不显示出来
  • ¥30 vue 页面窗口放大或者缩小元素会变化
  • ¥15 questasim仿真报错
  • ¥15 寻找电脑攻防的导师,有问题请教一下。
  • ¥20 微信同是win11,我的电脑安装不了pageoffice,一直无法打开
  • ¥15 这个界面我通过postman请求不到,但是通过浏览器可以正常访问
  • ¥15 多目标优化算法在与其他算法数据对比结果判断
  • ¥15 CPTN和EAST,主干网络是VGG16,请问在ICDAR2015数据集上训练之后,CPTN和EAST模型的大小为多少