get 提交
function getrequest ($url) { //初始化 $ch = curl_init(); //设置选项,包括url curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_header, 0); //执行并获取html文档内容 $output = curl_exec($ch); //释放curl句柄 curl_close($ch); return $output;}
post 提交
function postrequest($url, $data) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); // post数据 curl_setopt($ch, curlopt_post, 1); // post的变量 curl_setopt($ch, curlopt_postfields, $data); $output = curl_exec($ch); curl_close($ch); return $output;}
以上就介绍了php curl get post 提交函数,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。