php post无参数设置方法:1、通过ajax请求接口;2、客户端通过curl请求;3、在PHP服务端执行“file_get_contents("php://input");”。
本文操作环境:Windows7系统、PHP7.1版,DELL G3电脑
无参数名post数据客户端以及接口是如何实现的?
PHP版客户端:
1.第一种情况是客户端通过ajax请求接口。
立即学习“PHP免费学习笔记(深入)”;
$.ajax({ type: 'POST', url: url , data: data , success: success , dataType: dataType });
2.第二种情况是客户端可以通过curl请求。
$ch = curl_init(); //设置URL,POST方式提交以及POST数据 curl_setopt($ch, CURLOPT_URL, $apiurl); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, "post数据"); $result = curl_exec($ch);
PHP版服务端:
$sendjson=file_get_contents("php://input"); print_r($sendjson);
推荐学习:《PHP视频教程》
以上就是php post 无参数怎么设置的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号