[英]curl works fine in command line, but not in php
I use curl to retrieve the contents of a url from within PHP. 我使用curl从PHP中检索url的内容。 It works fine for most url's, but for some, it only returns an empty string ("curl"ing such url's from command line works just fine).
它适用于大多数url,但对于某些人来说,它只返回一个空字符串(从命令行“卷曲”这样的url工作正常)。 Here's how I run curl:
这是我运行curl的方式:
$curl_session = curl_init($site->url);
curl_setopt($curl_session, CURLOPT_HEADER, 0);
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_session, CURLOPT_CONNECTTIMEOUT, TIMEOUT);
$output = curl_exec($curl_session);
curl_close($curl_session);
I also checked and curl doesn't seem to give any errors. 我也检查和卷曲似乎没有给出任何错误。
您可以使用
echo shell_exec("www.example.com");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.