search
Homephp教程php手册php读取rss feed一例

RSS Feeds如今应用的非常广泛,基本上的网站都有这个功能,用来方便用户订阅最新的文章信息。 下面给出一个php读取rss feed的代码例子: ? phpheader ( Content-type: text/html; charset=utf-8 ); $file = file_get_contents ( http://www.3aj.cn/site/rss.

RSS Feeds如今应用的非常广泛,基本上的网站都有这个功能,用来方便用户订阅最新的文章信息。

 

下面给出一个php读取rss feed的代码例子:

 

<span></span><span>php
header</span><span>(</span><span>"Content-type: text/html; charset=utf-8"</span><span>);</span><span>

$file </span><span>=</span><span> file_get_contents</span><span>(</span><span>"http://www.3aj.cn/site/rss.xml"</span><span>);</span><span>
$xml </span><span>=</span><span>new</span><span>SimpleXMLElement</span><span>(</span><span>$file</span><span>);</span><span>foreach</span><span>(</span><span>$xml</span><span>-></span><span>channel</span><span>-></span><span>item </span><span>as</span><span> $feed</span><span>){</span><span>
    echo $feed</span><span>-></span><span>title</span><span>.</span><span>'<br>'</span><span>;</span><span>
    echo $feed</span><span>-></span><span>link</span><span>.</span><span>'<br>'</span><span>;</span><span>
    echo </span><span>'<br><br>'</span><span>;</span><span>}</span><span>?></span>

 

输出类似如下:

 

php生成随机密码
http://3aj.cn/php/93.html


php 计算"多久之前" 函数
http://3aj.cn/php/92.html


php读取csv文件简单一例
http://3aj.cn/php/91.html


php获取文件名后缀
http://3aj.cn/php/90.html


php计划任务
http://3aj.cn/php/89.html


Linux常用命令大全
http://3aj.cn/linux/88.html

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor