English 中文(简体)
在PHP中从另一个服务器读取XML文件的方式数量是多少?
原标题:
  • 时间:2008-10-28 17:39:31
  •  标签:

我正试图从另一台服务器读取XML文件。然而,托管我的公司似乎关闭了file_get_contents函数,以防止从其他服务器检索文件(并且它们的支持不是很好,需要很长时间才能回答)。因此,我需要以某种方式解决这个问题。

这是我当前的代码

 $url =  urldecode( $object_list_url );
 $xmlstr = file_get_contents ( $url );
 $obj = new SimpleXMLElement ( $xmlstr, LIBXML_NOCDATA );
最佳回答

You could use cURL (if that s not been disabled). Something like this:

$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$xmlstr = curl_exec($c);
问题回答

The ini var you re referring to is allow_url_fopen. To check, run this script:

var_dump(ini_get( allow_url_fopen ));

Ask your host to turn that ini value on (if it s disabled - it s on by default).

You should not be able to access any remote url without that ini setting on.

Also an idea if they won t could be to try copying the file to your server. I expect all filesystem functions will be covered by that ini setting but it s always worth a try.

Can you execute the following script and provide the information as a comment?

<?php
phpinfo();
?>




相关问题
热门标签