views:

49

answers:

1

Hello,

I am trying to get the (pre-processed) content of an external PHP file:

file_get_contents('http://www.example.org/myfile.php');

When I do this, I get an error:

Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /Applications/XAMPP/xamppfiles/htdocs/...localfile.php on line 13

And:

Warning: file_get_contents(http://www.example.org/myfile.php) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /Applications/XAMPP/xamppfiles/htdocs/.../localfile.php on line 13

Any ideas what I could do?

Thanks in advance!

EDIT: I do have allow_url_fopen set to "On".

+1  A: 

You can probably use cURL...

function curl($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    return curl_exec($ch);
    curl_close ($ch);
}


$string = curl('http://www.example.org/myfile.php'); //string with data
Webarto
Thanks, I'll try out whether it works - as soon as I can :DBy the way: `curl_close($ch)` is an unreachable statement ^^
arik-so
No it's not :) Only exit() will terminate function.
Webarto
ok. good to know :)
arik-so