0

I'm trying to display an image beside or before my description tag in my rss, I have tried on my localhost it worked like this:

<description><![CDATA[<img src="<?php echo $img; ?>">test test test test testtest test test test]]></description>

but on my website it's some kind different like this:

echo '
       <item>
          <title>'.$article[title].'</title>
          <description><![CDATA[<img src="$img_path">
          '.$shortdesc.'  
          ]]></description>
      </item>';

it's not working like this what is wrong in this ode? it's returnes blank iamge, here it's the page source from browser:

<description><![CDATA[<img src="$img_path">test test test</description>
4

1 回答 1

1

不会解析单引号内的 PHP 代码。

echo '
       <item>
          <title>'.$article['title']."</title>
          <description><![CDATA[<img src='{$img_path}'>
          ".$shortdesc.'  
          ]]></description>
      </item>';

或者

echo '
       <item>
          <title>'.$article['title'].'</title>
          <description><![CDATA[<img src="'.$img_path.'">
          '.$shortdesc.'  
          ]]></description>
      </item>';
于 2012-09-02T22:33:23.570 回答