note 124911 deleted from info.configuration by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:29:45 +0000 |
| Subject: | note 124911 deleted from info.configuration by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215180@lists.php.net to get a copy of this message | ||
Note Submitter: csongor at halmai dot hu
----
The max_input_vars setting is defined as "How many input variables may be accepted" but
this is not completely correct. There is a +1 factor.
For example, if the value is 2 then the $_POST array can have up to 3 elements, if it is 1000 then
it can have 1001 elements, and so on.
I want to stop the execution of the php code when there is a chance that some data was not received.
Therefore, instead of relying on the standard E_WARNING, I do this in my code.
<?php
$max_input_vars = ini_get('max_input_vars');
if (count($_POST) === $max_input_vars + 1) { // note the +1 here
throw new Exception();
}
?>
If the size of the $_POST array reaches the maximum then there is the chance that there was more
data so it is better to stay on the safe side and increase the config value.