dsfsw1233 2012-04-11 19:30
浏览 28
已采纳

RSS Feed不显示PHP变量

I have an RSS feed which for some reason is not showing my PHP variables. When the feed is returned it comes back with the raw tags for example the title will be Timetable $yesterdayd instead of Timetable - Tuesday 10th April

<?PHP
 include("../config.php");
 #// Timetable Clearup Variabls
$yesterday = strtotime('yesterday');
$yesterdow = date('l',$yesterday);
$order = "SELECT * FROM timetable WHERE day = '$yesterdow' ORDER BY time";
$result = mysql_query($order);
$yesterdayd = date('F jS, Y', time()-86400);

    //SET XML HEADER
    header('Content-type: text/xml');

    //CONSTRUCT RSS FEED HEADERS
    $output = '<rss version="2.0">';
    $output .= '<channel>';
    $output .= '<title>Timetable - $yesterdayd </title>';
    $output .= '<description>Timetable.</description>';
    $output .= '<link>http://site.com/</link>';
 ###   $output .= '<copyright>Your copyright details</copyright>';

    //BODY OF RSS FEED
   $output .= '<item>';
        $output .= '<title>Timetable for $yesterdayd</title>';
        $output .= '<description>" . htmlspecialchars($row['username']) . "</td><td>" . htmlspecialchars($row['time']) . "</description>';
        $output .= '<link>Link to Item</link>';
        $output .= '<pubDate>Date Published</pubDate>';
   $output .= '</item> ';

    //CLOSE RSS FEED
   $output .= '</channel>';
   $output .= '</rss>';

    //SEND COMPLETE RSS FEED TO BROWSER
    echo($output);

?>

Any ideas?

  • 写回答

2条回答 默认 最新

  • dongzanghua8422 2012-04-11 19:33
    关注

    Use double quotes for the output strings. The variables don't interpolate with single quotes I think.

    So like

    $output .= "<title>Timetable for $yesterdayd</title>";
    

    That should do it. The page DOES have a php extension, right?

    EDIT:

    When you're interpolating arrays or objects, use syntax like this {$row['username']} or {$object->property}, but when you're calling a function, you cannot interpolate, you MUST concatenate:

    "<description>" . htmlspecialchars($row['username']) . "</td>";
    

    Also, make sure you're not now mixing single and double quotes -- it looks like the code you pasted as a response mixes them.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题