gpt4 book ai didi

PHP & RSS 提要和特殊字符验证问题

转载 作者:搜寻专家 更新时间:2023-10-31 20:53:54 24 4
gpt4 key购买 nike

我不断收到以下验证警告。我想知道我的一些文章涉及特殊字符,并且想知道我应该如何在我的 RSS 提要中渲染或不渲染特殊字符?我应该使用 htmlentites 吗?如果是怎么办?

In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations. line 22, column 35: title should not contain HTML: &

PHP 代码。

<title>' . htmlentities(strip_tags($title), ENT_QUOTES, "UTF-8") . '</title>

最佳答案

您应该使用 CDATA 来转义 XML 提要中的字符,这样您就可以在不破坏 XML 布局的情况下使用原始数据。

试试这个:

<title><![CDATA[ YOUR RAW CONTENT]]></title>

注意:不要使用 htmlentites 和 strip_tags,因为这会为浏览器转义它们,任何其他读者都应该正确阅读它们。

来自 w3schools 的引述:

The term CDATA is used about text data that should not be parsed by the XML parser. Characters like "<" and "&" are illegal in XML elements. "<" will generate an error because the parser interprets it as the start of a new element. "&" will generate an error because the parser interprets it as the start of an character entity. Some text, like JavaScript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA. Everything inside a CDATA section is ignored by the parser. A CDATA section starts with "":

http://www.w3schools.com/xml/xml_cdata.asp

关于PHP & RSS 提要和特殊字符验证问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4702835/

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