file_get_contents()没有返回?

con*_*dor 1 php file-get-contents

为什么我没有得到file_get_contents($ myurl)的回报,但我确实获得了wget的输出

更新:

我使用curl获取返回标题和结果,并发现它在标题上而不是在正文中

HTTP/1.1 200 Document follows
Transfer-Encoding: chunked
Content-type: text/plain
Server: XMS (724Solutions HTA XSAM_30_M2_B020 20070803.172831)
Date: Fri, 21 May 2010 10:48:31 GMT
Accept-Ranges: bytes

HTTP/1.1 404 ChargedPartyNotAvailable
Transfer-Encoding: chunked
Content-type: text/plain
Server: XMS (724Solutions HTA XSAM_30_M2_B020 20070803.172831)
Date: Fri, 21 May 2010 10:34:13 GMT
Accept-Ranges: bytes
Run Code Online (Sandbox Code Playgroud)

我怎样才能提取出"200 Document Follow"和"404 ChargedPartyNotAvailable"?

Tom*_*igh 5

你在php配置中启用了allow_url_fopen吗?

但是我希望你会收到一个警告 - 如果没有 - 你有没有显示错误/警告?您可以临时添加到脚本的顶部:

error_reporting(E_ALL);
ini_set('display_errors', true);
Run Code Online (Sandbox Code Playgroud)

然后你可能会发现为什么file_get_contents()不起作用.

编辑

get_headers()如果您只对标题感兴趣,则可能只能使用.