Home  >  Article  >  Backend Development  >  PHP中的n、r、t不起作用解决方案

PHP中的n、r、t不起作用解决方案

WBOY
WBOYOriginal
2016-06-13 10:37:331071browse

PHP中的\n、\r、\t不起作用
  $a="This string will $print.\nAnd this is another line.";
  echo $a;
?>
程序的输入结果为什么是 This string will . And this is another line.
而不是
  This string will .
  And this is another line. 呢?
教材上面明明写的是后者啊!
而且我把\n换为\t或者\r输出结果是一样的,三个符号只是起到了空格的作用,而不是应有的换行、制表、回车的功能,为什么呢?恳请高手指点,谢谢!

------解决方案--------------------

<br><?php <br /> $a="This string will $print.\nAnd this is another line.";<br> echo $a;<br>?><br>

------解决方案--------------------
不是告诉你了吗,\r\n只对写文件或是多行文本框中才会起作用,要是windown的东西才认,html是不认这东西的,
 标签可定义预格式化的文本我理解也只是对这东西做了转化<br><font color="#e78608">------解决方案--------------------</font><br>咳咳,<br>在html里, 回车/tab/空格 这些都叫做whitespace,  <br>任何多个连续的whitespace在html都被显示为"一个空格"<br><br>这就是这么规定的...<br><br><pre class="brush:php;toolbar:false">里会原样显示这些字符<br><br>也就是这么规定的,<br><br>所以说要看html的书....<br><br>如果要显示很多空格怎么办.... 楼上说了,   <br>如果要回车... <br>  <p>等<br>如果要tab, ....如果你要显示表格最好是</p>
, 或者
  • 有时也行
    更好的方法是用css控制你的显示

    为什么没说
    ,这个tag比较特殊,如果你不是真的只要显示纯文本,就不该用<br><br>html的显示的一般文本的显示是两回事....所以叫"超"文本<br><br><br><div class="clear">
                     
                  
                  
            
                </div>
  • Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn