PHP curl get post 提交函数
程序员文章站
2022-04-04 19:47:19
...
get 提交
post 提交
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教程有兴趣的朋友有所帮助。
上一篇: html5属性值两边用什么符号
下一篇: php函数都分为哪两种?
推荐阅读
-
php中get_defined_constants函数用法实例分析_PHP
-
php发送post请求函数分享_PHP
-
PHP的cURL库功能简介:抓取网页,POST数据及其他_PHP教程
-
ini_set /ini_get函数功能-----PHP
-
php get_headers 与get_meta_tags函数实例_PHP教程
-
php中file_get_contents与curl性能比较分析,curlgetcontents
-
php自动提交表单的方法(基于fsockopen与curl),fsockopencurl
-
PHP $ _POST函数 与$_GET函数详解
-
PHP获得内存使用状态memory_get_usage()函数
-
php中file_get_contents与curl性能比较分析