微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php $_POST计数问题

什么是获得$_POST计数的最佳方法

我有一个用户可以创建输入框的表单,所以我不想允许空提交.

我试过计数($_ POST),它总是空的.这个

if(!isset($_POST['submit'])) {
//codes
}
else {
die(count($_POST)); // return as empty
}

什么是获得$_POST数量的最佳方法

解决方法:

请注意,它是一个整数,你传递给die()(别名为exit())!这有一个特殊的含义:

If status [the argument] is an integer, that value
will be used as the exit status and
not printed. Exit statuses should be
in the range 0 to 254, the exit status
255 is reserved by PHP and shall not
be used. The status 0 is used to
terminate the program successfully.

(我的重点)

简单的解决方法

if(!isset($_POST['submit'])) {
   //codes
} else {
   die('count=' . count($_POST)); // Now a String
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐