输入banner图图片脚本导航/分类

php post 无参数怎么设置

php post无参数设置方法:1、通过ajax请求接口;2、客户端通过curl请求;3、在PHP服务端执行“file_get_contents("php://input");”。

本文操作环境:Windows7系统、PHP7.1版,DELL G3电脑

无参数名post数据客户端以及接口是如何实现的?

PHP版客户端:

1.第一种情况是客户端通过ajax请求接口。

 $.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 无参数怎么设置的详细内容,更多请关注gxlcms其它相关文章!