Php simplexml_load_file () with password protected url

A simple question for someone who knows the answer ...

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

This url is protected .htaccess, how can I pass login / password as arguments to a function?

+4
source share
3 answers
$xml = simplexml_load_file("http://username:password@url/path/file.xml");

Try it :)

+8
source

file_get_contentsor curl will allow you to set user authentication using http://username:password@url/path/file.xml.

Take the string data and pass in simplexml_load_string.

+1
source

allow_url_fopen allow_url_include php.ini( propriertary.htaccess), . , .

.htaccess :

php_value allow_url_fopen 1
php_value allow_url_include 1
+1

Source: https://habr.com/ru/post/1748165/


All Articles