6

给知道答案的人一个简单的问题...

$xml = simplexml_load_file("http://url/path/file.xml");

此 url.htaccess受保护,如何将登录名/密码作为参数传递给函数?

4

3 回答 3

10
$xml = simplexml_load_file("http://username:password@url/path/file.xml");

试试看:)

于 2010-06-02T14:46:38.823 回答
1

file_get_contents或 curl 将允许您使用http://username:password@url/path/file.xml.

获取字符串数据并传入simplexml_load_string.

于 2010-06-02T14:45:46.223 回答
1

必须先在 php.ini(或专有的 .htaccess)中打开 allow_url_fopen 和 allow_url_include,然后才能执行此操作。它很可能没有在您的服务器上设置,必须手动更改。

具有这些值的示例 .htaccess 设置将是:

php_value allow_url_fopen 1
php_value allow_url_include 1
于 2011-11-21T05:35:24.020 回答