Problem with rss channel and cdata

I have a problem with rss feed.

When i do <title>This is a title </title>

The title is perfectly displayed in the feed

But when I ddo $ title = "this is tilte";

<title><![CDATA['$title']]></title>

The name does not appear at all.


It still does not work. I generate my rss feed dynamically and it looks like this:

$item_template="
      <item>
         <title>[[title]]</title>
         <link>[[link]]</link>
         <description><![CDATA[[[description]]]]></description>
         <pubDate>[[date]]</pubDate>
      </item>
      ";

and in the loop:

$s.=str_replace(
array("[[title]]","[[link]]","[[description]]","[[date]]"),
array(htmlentities($row["title"]),$url,$description,$date),
$item_template);

The problem is that the name has a euro sign. Then it appears in my rss validator, for example:

Â\x80

More detailed information:

Well, I have been struggling with this for the past few days, and I cannot find a solution. Therefore, I will begin generosity. Here is additional information:

  • The information that goes into the feed is stored in the latin 1 database (which I administer)
  • The problem occurs when there is an euro sign in the database. No matter how possible, or&euro;
  • The euro sign sometimes appears as strange characters or as  \ x80
  • .
  • : codedump
  • : , , ( , ) . , , <title></title>

, , .

+3
6

- ;

echo '<title><![CDATA[$title]]></title>';

echo '<title><![CDATA[' . $title . ']]></title>';

: , . . .

, : htmlentitites , :

echo '<title>' . htmlentities($title, ENT_NOQUOTES, [encoding]) . '</title>';

[encoding] , . , "UTF-8". , php (< 6) ISO-8859-1 , , . . . .

XML. .

+15

htmlspecialchars() htmlentities().

RSS/ATOM- HTML, HTML-. XML , , &euro;. UTF - , ( htmlentities), (htmlspecialchars).

RSS/XML. , , - ( RSS ).

+3

? , PHP .

. , PHP.

, :

<title><![CDATA[$title]]></title>
+1

, . , , . - CDATA , XML - XML. PHP: DomDocument XML Writer (http://php.net/manual/en/book.xmlwriter.php)

0

, RSS : , title , .

-1

This article may be useful for information on the euro sign and support in various contexts. Some of the sentences in this article include the use &#8364;or &euro;or simply replacement of the mark with the word "euro." Good luck

-1
source

Source: https://habr.com/ru/post/1707588/


All Articles