在 PHP 中执行此 cURL
如何在 PHP 中完成此操作
curl -I http://www.google.com | grep "Server:"
?是否可以仅回显 Linux 等操作系统或网站的 Windows,例如使用curl 回显 Web 服务器
My Try
<?
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,"http://google.com");
curl_setopt ($ch, CURLOPT_HEADER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
echo $data ;
?>
how can this be done in PHP
curl -I http://www.google.com | grep "Server:"
and is it possible to just echo OS like Linux Or windows of site , like web server is echoed using curl
My Try
<?
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,"http://google.com");
curl_setopt ($ch, CURLOPT_HEADER, 1);
$data = curl_exec ($ch);
curl_close ($ch);
echo $data ;
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,这是Horde_Http 库的摘录。具体来说Curl 请求 和 Curl 响应 处理程序。
它比您使用“grep”命令所做的要复杂一些,但看起来您想分析响应标头。这就是为什么我在代码中留下了更复杂的标头分析。
Basically this is an extract from the Horde_Http library. Specifically the Curl request and the Curl response handlers.
It is somewhat more complex than what you did with your "grep" command but it looked as though you want to analyse the response headers. That is why I left the somewhat more complex header analysis in the code.