gpt4 book ai didi

php - HTML 和 PHP 中的 'Line feeds' 到底是什么意思?它们如何添加到 HTML 和 PHP 代码中?

转载 作者:行者123 更新时间:2023-11-27 23:09:07 24 4
gpt4 key购买 nike

我在阅读 PHP 手册时遇到了以下文本段落:

Line feeds have little meaning in HTML, however it is still a good idea to make your HTML look nice and clean by putting line feeds in. A linefeed that follows immediately after a closing ?> will be removed by PHP. This can be extremely useful when you are putting in many blocks of PHP or include files containing PHP that aren't supposed to output anything. At the same time it can be a bit confusing. You can put a space after the closing ?> to force a space and a line feed to be output, or you can put an explicit line feed in the last echo/print from within your PHP block.

我有以下与上一段文字相关的问题:

  1. HTML 中的“换行”到底是什么意思?
  2. 如何将它们添加到 HTML 代码和 PHP 代码中并使其在网络浏览器中可见?哪些 HTML 实体/标签/字符用于实现此目的?
  3. 对于 HTML 和 PHP,“换行”的含义是否相同?如果不是,两种上下文中的含义有何不同?
  4. 为什么 PHP 手册在段落的第一行中这样说? PHP Manual 想通过下面的句子表达什么?

"Line feeds have little meaning in HTML"

  1. 当有人放入许多 PHP block 或包含不应输出任何内容的 PHP 文件时,删除紧跟在结束标记之后的换行符有何用处?

请有人用简单、清晰和易于理解的语言给出答案,以消除我的上述疑问。如果有人可以通过合适的工作代码示例来回答答案,那将对我更清楚地理解这个概念有很大帮助。

谢谢。

最佳答案

What does exactly mean by 'Line feeds' in HTML?

这是一个通用的计算术语。

The character (0x0a in ASCII) which advances the paper by one line in a teletype or printer, or moves the cursor to the next line on a display.

source: Wiktionary

How to add them to the HTML code

按键盘上的回车键。请注意(有几个异常(exception),如 <pre> )所有空白字符在 HTML 中都是可互换的。新行将被视为一个空格。

as well as PHP code

同上……或者您可以使用转义序列 \n在字符串文字中。

and make visible in a web browser?

你引用的 Material 是关于让源代码看起来更漂亮。您通常不希望换行符在浏览器中可见。

你可以使用 <pre>元素代替。

<pre> 之外元素(以及它们默认具有的 CSS 设置),您可以使用空格而不是新行来实现 HTML 中的相同效果。

What HTML entities/tags/characters are used to achieve this?

&#10;

……但是您引用的 Material 最后一句话中给出的建议可能是更好的方法。

关于php - HTML 和 PHP 中的 'Line feeds' 到底是什么意思?它们如何添加到 HTML 和 PHP 代码中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47258581/

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