我正在尝试使用此方法在我的数据库中读取和存储 RSS 提要。
<?php
$homepage = file_get_contents('http://www.forbes.com/news/index.xml');
$xml = simplexml_load_string($homepage,'SimpleXMLElement', LIBXML_NOCDATA);
echo '<pre>';
print_r('$xml');
?>
但:
1. How can I check if `$homepage` contains a valid XML file or not?
2. I'm want to know how much time its taken to call if the url is valid XML file
$homepage = file_get_contents('http://www.forbes.com/news/index.xml');
使用 try 和 catch 异常..