Html 做 & 或 & 或 & 在代码中的意思相同?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8511295/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 12:01:28  来源:igfitidea点击:

Does & or & or & mean the same thing in code?

htmlwordpress

提问by Leon Gaban

We have a client that uses a wordpress blog, when he pastes in our video embed code it changes &'s into &so for a workaround he has to re-write &as &

我们有一个使用 wordpress 博客的客户,当他粘贴我们的视频嵌入代码时,它会更改为&这样的解决方法,他必须重新编写&&

Does this break code? Would doing something like <code></code>in wordpress fix the issue?

这会破坏代码吗?<code></code>在 wordpress 中做类似的事情会解决这个问题吗?

Example:

例子:

<param name="adServerURL" value="http://plg.website.com/dynamic_preroll_playlist.vast2xml?domain=111aaabbb&amp;pubchannel=KidS&amp;" />

回答by Robert

Technically yes they are all the same thing. Since it's wordpress I would recommend using the &#038;as that's the encoded version of the ampersand & or &amp;.

从技术上讲,是的,它们都是一样的。由于它是 wordpress,我建议使用 ,&#038;因为这是 & 的编码版本& or &amp;

WordPress references:

WordPress 参考资料:

http://wordpress.org/support/topic/how-to-get-rid-of-amp-and-038

http://wordpress.org/support/topic/how-to-get-rid-of-amp-and-038

http://wordpress.org/support/topic/unwanted-characters-038

http://wordpress.org/support/topic/unwanted-characters-038

回答by Jukka K. Korpela

I'm not sure of what you mean, as your text refers to changing & into &. Probably you meant changing the ampersand letter & to &amp;, but here you need to use the “{ }” button to “escape” it to make it visible.

我不确定您的意思,因为您的文字是指将 & 更改为 &。可能您的意思是将与号字母 & 更改为&amp;,但在这里您需要使用“{}”按钮来“转义”它以使其可见。

It's a correct change. In HTML, the ampersand has a special meaning, and this applies to occurrences in URLs, too. Mostly you can get away with it if you don't “escape” it, but escaping is the right thing to do—failing to do so may sometimes break the code.

这是一个正确的改变。在 HTML 中,& 符号具有特殊含义,这也适用于 URL 中的出现。大多数情况下,如果你不“逃避”它,你就可以逃脱它,但逃避是正确的做法——不这样做有时可能会破坏代码。

Using <code>markup has no impact on this.

使用<code>标记对此没有影响。