17c05-1.php

来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 52 行

PHP
52
字号
<?php// Create our array of news stories.  // These might have come from a database originally:$news = array(  array('Man hates politics', 'http://example.com/23423.php',    'A man has been found that hates politics.  Politicians are surprised.'),  array('Cat eats mouse', 'http://example.com/83482.php',    'A cat was found eating a mouse.  The mouse was very surprised.'),  array('Programmer gets hired', 'http://example.com/03912.php',    'A programmer has received a telecommuting agreement, and is happy.'),    );// Now, first to create our RSS feed, start with the appropriate header:header('Content-type: text/xml');// Echo out the opening of the RSS document.  These are parts that just//  describe your website, and what the RSS feed is about:echo '<?xml version="1.0" ?>';echo <<<EORSS<rss version="2.0">  <channel>    <title>Not So Nifty News Stories (NSNNS)</title>    <link>http://example.com/nsnns.php</link>    <description>The best news stories we can legally find!</description>    <language>en-us</language>    <copyright>Copyright 2006 - NSNNS</copyright>    <webMaster>webmaster@example.com</webMaster>    <generator>A Custom PHP Script</generator>EORSS;// Now that we've taken care of that, we can echo out each news item// So just start looping through them!foreach ($news as $item) {    // Well, not much fancyness needed, just echo them out:    echo <<<EOITEM    <item>      <title>{$item[0]}</title>      <link>{$item[1]}</link>      <description>{$item[2]}</description>    </item>EOITEM;}// Almost done.  Just need to print a few closing tags now and that's it:echo <<<EOCLOSE  </channel></rss>EOCLOSE;?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?