PHP file_get_contents()无法正常工作 [英] PHP file_get_contents() not working
本文介绍了PHP file_get_contents()无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以解释为什么以下代码返回警告:
Can anyone explain why the following code returns a warning:
<?php
echo file_get_contents("http://google.com");
?>
我收到警告:
Warning: file_get_contents(http://google.com):
failed to open stream: No such file or directory on line 2
请参见键盘
推荐答案
或者,您可以使用cURL,例如:
As an alternative, you can use cURL, like:
$url = "http://www.google.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
请参阅: cURL
这篇关于PHP file_get_contents()无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文