我正在尝试使用此方法在我的数据库中读取和存储RSS提要。file_get_contents和有效的xml的响应时间
<?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异常..
@Brendan龙..感谢先生,以正确的方式解释我的要求。 – omnath