The problem with the php $ _POST schedule

What is the best way to get the $ _POST counter

I have a form in which the user can create an input field, so I do not want to allow empty submission.

I tried count($_POST), it is always empty. It's in

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

What is the best way to get a $ _POST account?

+3
source share
2 answers

Please note that this is an integer that you pass in die()(an alias for exit())! This is of particular importance:

status [] , . 0 254, 255 PHP . 0 .

( )

:

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

:) , POST, $_SERVER ['REQUEST_METHOD'].

, PHP? PHP 4.1, .

http://php.net/manual/en/language.variables.predefined.php

+3

Source: https://habr.com/ru/post/1770100/


All Articles