file_get_contents()的等效函数?

oop*_*ase 7 php file-get-contents

我想从html页面解析一些信息.目前我解决了这样的问题:

header("Content-type: text/plain");    
$this->pageSource = file_get_contents ($this->page);
header("Content-type: text/html");
Run Code Online (Sandbox Code Playgroud)

$this->page是该网站的网址.这在XAMPP上工作正常,但是当我在我的网络服务器上传我的脚本时,我收到以下错误消息:

警告:file_get_contents()[function.file-get-contents]:http://在服务器配置中禁用包装器allow_url_fopen = 0

显然我不允许在我的网络服务器上执行该功能.

那么有一个等价的功能来解决我的问题吗?

ajr*_*eal 20

实际上该功能file_get_contents未被禁用,
allow_url_fopen被禁用

你可以用它替换它 curl

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->page);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$this->pageSource = curl_exec($ch);
curl_close($ch);
Run Code Online (Sandbox Code Playgroud)

但是,如果您的服务器阻止传出流量,curl也没有帮助