脚本宝典收集整理的这篇文章主要介绍了php生成curl命令行的方法,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
本文实例讲述了PHP生成curl命令行的方法。分享给大家供大家参考,具体如下:
示例: curl "http://localhost/other/serverInfo.PHP?dd=ddd" -H "Host:localhost" -H "Connection:keep-alive" -H "Cache-Control:max-age=0" -H "Accept:text/htML,application/xhtml+XMl,application/xml;q=0.9,image/webp,*/*;q=0.8" -H "User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) Applewebkit/537.36 (KHTML,like Gecko) Chrome/43.0.2357.132 Safari/537.36" -H "DNT:1" -H "Accept-Encoding:deflate,sdch" -H "Accept-Language:zh-CN,zh;q=0.8,en;q=0.6" -H "Cookie:name=richie; email=richie@QQ.COM"
具体代码如下:
$value) { if (substr($name,5) == 'HTTP_') { $headers[str_replace(' ','-',ucwords(strtolower(str_replace('_',' ',substr($name,5)))))] = $value; } } } foreach ($headers as $key => $value) { if($key == 'Accept-Encoding') $value = str_replace('gzip,','',$value); $curlCommand .= ' -H "' . $key . ':' . $value . '"'; } return $curlCommand; } catch (Exception $e) { return $e->getMessage(); } } echo getCurlCommand();
以上是脚本宝典为你收集整理的php生成curl命令行的方法全部内容,希望文章能够帮你解决php生成curl命令行的方法所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。