php接受post接受不到数据,PHP$_POST接受不到数据,但$_GET可以接受数据

新手一枚,代码如下,把post 改成 get 就没问题,但如果是post 就会提示

Notice: Undefined index: a in D:\xampp\htdocs\myphp\add.php on line 3

add.html

Title

add.php

回复内容:

新手一枚,代码如下,把post 改成 get 就没问题,但如果是post 就会提示

Notice: Undefined index: a in D:\xampp\htdocs\myphp\add.php on line 3

add.html

Title

add.php

我也是类似的问题,只有一种可能,就是你得phpstrom配置的端口与phpinfo()端口不符。先看一下

php.ini 中配置 enable_post_data_reading 为 On, 这样才会自动将 POST 数据填入 $_POST 数组中。

; Whether PHP will read the POST data.

; This option is enabled by default.

; Most likely, you won't want to disable this option globally. It causes $_POST

; and $_FILES to always be empty; the only way you will be able to read the

; POST data will be through the php://input stream wrapper. This can be useful

; to proxy requests or to process the POST data in a memory efficient fashion.

; http://php.com/enable-post-data-reading

; enable_post_data_reading = Off

判断是否输入a和b的值,应该使用:

isset($_POST['a']) && isset($_POST['b']

你的写法在a或b输入0值时,不会走相加分支。

打印 $_REQUEST数组,

如果查验是否有数据POST过来,如果没有确定的条件下,推荐在业务处理前先进行打印数据。

上面可以直接

var_dump($_POST);

看下是否有值。

post有好几种方式,你看你是什么方式提交的?

php配置问题吧

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:php中文网

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值