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