I want to parse some information out of a html page. Currently I solve the problem like this:
header("Content-type: text/plain");
$this->pageSource = file_get_contents ($this->page);
header("Content-type: text/html");
$this->page
is the url of the website.
This works fine on XAMPP, but when I upload my script on my webserver, I get the following error message:
Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0
So obviously I am not allowed to execute that function on my webserver.
So is there an equivalent function to solve my problem?
if you have curl, use it it is great for this.
Use
curl
and why do you need to change the header to plain text to retrieve data? This is not necessary if you are retrieving data.cURL is the usual standard solution.
Actually the function
file_get_contents
is not disabled,but
allow_url_fopen
is disabledyou can replace it with
curl
However, if you server block outgoing traffic,
curl
does not help tooUse
curl()
.