我使用fopen或curl在PHP中给定一个URL来加载XML文件 [英] Do I use fopen or curl to load an XML file given a URL in PHP
本文介绍了我使用fopen或curl在PHP中给定一个URL来加载XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可以通过URL获取的XML文件。我知道我可以使用 fopen
获得文件,但有时我看到脚本使用 curl
。使用 curl
over fopen
获得XML文件有什么优势吗?
code> simplexml_load_file($ filename);
但是,有些服务器会限制从此函数加载网址。在这种情况下,您只能使用cURL。
I have an XML file I can get via a URL. I know I can get the file using fopen
, but sometimes I've seen scripts use curl
. Is there an advantage to using curl
over fopen
to get XML files?
解决方案
Well, if you are going to use SimpleXML to load the file you can use
simplexml_load_file($filename);
However, some servers will restrict loading urls from this function. In this case you would be restricted to cURL.
这篇关于我使用fopen或curl在PHP中给定一个URL来加载XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文