我只是使用 file_get_contents 来检索我网站中的数据。但它不返回任何东西。
file_get_contents("https://www.google.co.in/images/srpr/logo11w.png")
当我在本地环境中使用它时,它会返回值。
我还在我的网站上尝试了 curl 以确定它是否返回任何内容。但它显示
Forbidden
您没有访问权限。
我用谷歌搜索,我发现了一些提示。我启用了 allow_url_fopen和allow_url_include。
但没有任何工作。
我尝试过的卷曲代码
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$return = curl_exec($ch); curl_close ($ch);
return $return;
}
$string = curl('https://www.google.co.in/images/srpr/logo11w.png');
echo $string;