vin*_*avn 7 php curl file-get-contents phpinfo
我刚刚使用file_get_contents来检索我网站上的数据.但它不会返回任何东西.
file_get_contents("https://www.google.co.in/images/srpr/logo11w.png")
Run Code Online (Sandbox Code Playgroud)
当我在我的本地环境中使用它时,它返回值.
我也尝试在我的网站上卷曲,以确定它是否返回任何东西.但它表明
禁止
您无权访问.
我用Google搜索,我发现了一些提示.我启用了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;
Run Code Online (Sandbox Code Playgroud)
file_get_contents()...<?php
header('Content-Type: image/png');
echo file_get_contents("https://www.google.co.in/images/srpr/logo11w.png");
Run Code Online (Sandbox Code Playgroud)
cURL...<?php
header('Content-Type: image/png');
function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$return = curl_exec($ch); curl_close ($ch);
return $return;
}
$string = curl('https://www.google.co.in/images/srpr/logo11w.png');
echo $string;
Run Code Online (Sandbox Code Playgroud)
输出 :
