您好,欢迎访问一九零五行业门户网

php curl使用

##### php curl使用php curl更改页面信息```/*$curlobj = curl_init();//初始化curl_setopt($curlobj,curlopt_url,http://www.baidu.com); //设置访问页面的urlcurl_setopt($curlobj,curlopt_returntransfer,true); //执行后不直接打印出来$output = curl_exec($curlobj); //执行curl_close($curlobj); //关闭curlecho str_replace(百度,dll,$output);*/```使用curl获取图片信息```header(content-type: text/html; charset=utf-8);@header('content-type:image/jpg');$ch = curl_init();$url=http://ww1.sinaimg.cn/mw690/78f2cc43jw1f2vtybda98j206y046t8y.jpg;curl_setopt($ch,curlopt_url,$url);curl_setopt($ch,curlopt_returntransfer,1); $output = curl_exec($ch);$info = curl_getinfo($ch);file_put_contents(abc.jpg,$output);curl_close($ch);```使用curl模拟post表单,上传文件```$url = http://localhost/phpcurl/out.php;$post_data = array( name => gewenrui, password =>123);$ch = curl_init();curl_setopt($ch,curlopt_url,$url);curl_setopt($ch,curlopt_returntransfer,1);curl_setopt($ch,curlopt_post,1);curl_setopt($ch,curlopt_postfields,$post_data);curl_setopt($ch,curlopt_timeout,10);$output = curl_exec($ch);$info = curl_getinfo($ch);//echo '获取'.$info['url'].'耗时'.$info['total_time'].'秒'.$info['request_size'];curl_close($ch);echo $output;上传文件$url = http://localhost/phpcurl/out.php;$post_data = array( fool => bar, //上传文件此处需要添加@符号 upload => @abc.jpg);$ch = curl_init();curl_setopt($ch,curlopt_url,$url);curl_setopt($ch,curlopt_returntransfer,1);curl_setopt($ch,curlopt_post,1);curl_setopt($ch,curlopt_postfields,$post_data);$output = curl_exec($ch);curl_close($ch);echo $output;```使用curl实现批处理j```
其它类似信息

推荐信息