发布于 2015-09-09 20:58:21 | 175 次阅读 | 评论: 0 | 来源: PHPERZ

这里有新鲜出炉的精品教程,程序狗速度看过来!

Kohana PHP5框架

Kohana 是一款纯 PHP5 的框架,基于 MVC 模式开发, 它的特点就是高安全性,轻量级代码,容易使用。 2009年9月发布了3.0版本,支持HMVC模式。


创建Feed
Feed::create()方法用给定的参数来创建 RSS戒者 Atom feed。下面是可接受的参数。
■  info:你 feed 中的 header 详绅信息的数组,如 pubDate 和 description
■  items:一个填满了你 feed 项目的数组
■  format:你的 feed 的格式,默认是 rss2

■  encoding:你的 feed 使用的编码,默认是 UTF-8

效果如图:

下面癿例子从一个博客数据例子的数组创建一个 feed

    $info = array(  
        'title' => 'My Feed Title',  
        'pubDate' => date("D, d M Y H:i:s T"),  
        'description' => 'My recent blog posts',  
    );  
    $items = array(  
        array(  
            'title' => 'My Post Title',  
            'link' => 'blog/post/45',  
            'description' => 'This is the content summary of my post',  
        ),                array(  
            'title' => 'Another Post Title',  
            'link' => 'blog/post/46',  
            'description' => 'This is the content summary of my post',  
        ),  
        array(  
            'title' => 'Yet Another Post Title',  
            'link' => 'blog/post/47',  
            'description' => 'This is the content summary of my post',  
        ),  
    );  
      
    $xml = Feed::create($info, $items);  
    print_r($xml); die;  


这个将生成下列癿 XML

    <?xml version="1.0" encoding="UTF-8"?>   
       <rss version="2.0">   
         <channel>   
           <pubDate>Fri, 11 Dec 2009 15:57:51 CST</pubDate>   
           <description>My recent blog posts</description>   
           <title>My Feed Title</title>   
           <link>http://www.example.com/</link>   
           <generator>KohanaPHP</generator>   
           <item>   
             <title>My Post Title</title>   
             <link>http://gallery.artmoi.com/blog/post/45</link>   
             <description>This is the content summary of my   
    post</description>   
           </item>   
           <item>   
             <title>Another Post Title</title>   
             <link>http://gallery.artmoi.com/blog/post/46</link>   
             <description>This is the content summary of my   
    post</description>   
           </item>   
           <item>   
             <title>Yet Another Post Title</title>   
             <link>http://gallery.artmoi.com/blog/post/47</link>   
             <description>This is the content summary of my   
    post</description>   
           </item>   
         </channel>   
       </rss>   


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务