0
我正在读取一个数字的XML文件。然后,它使用该数字作为可用作XML的URL参数。有一些XML不存在的情况。当发生这种情况时,我希望页面可以报告没有该游戏的统计数据。检查xml是否存在(simplexml_load_file)
TL; DR:如果XML不存在,我怎么才能让它简单地回显“No Stats”。
$gamepage = simplexml_load_file('' . rawurlencode($gamelink) . '?xml=1');
XML是一个本地文件,还是你通过http拉?如果是本地的,只是['file_exists()'](http://us3.php.net/manual/en/function.file-exists.php) – 2012-08-05 22:13:35
它不是本地的 – user1568736 2012-08-05 22:14:28
请参阅http://stackoverflow.com/questions/1722613/check-if-a-remote-page-exists-using-php and [many other examples](http://stackoverflow.com/search?q=%5Bphp%5D+remote+file+exists)。 – 2012-08-05 22:17:08