Is there a limit like max_input_vars in versions b

2019-01-28 01:38发布

问题:

It seems like there is a problem with older PHP versions and more than 1000 input fields in one form (see this question).

If I run a webserver with an older PHP version, is there a limit to the maximum number of form elements in (one nesting level) like it is controlled by the php.ini directive max_input_vars since PHP 5.3.9?

Or is there no limit in older versions?

What happens if I set this variable anyway in older versions in php.ini or .htaccess?

I noticed, that on my server I run PHP 5.3.3-7+squeeze17 which also already has the directive max_input_vars.

How exactly did older versions behave?

回答1:

It seems there is confusion:

http://www.flowstopper.org/2012/12/my-php-wtf-of-day-maxinputvars.html

Although the docs say: "Available since PHP 5.3.9."

http://php.net/manual/en/info.configuration.php

If I had to guess I would say there was always a limit, and it just got pulled out into the config/documentation in 5.3.9



回答2:

There seems to be a bug in older versions:

https://bugs.php.net/bug.php?id=65778

although you can alter the directive in php.ini and the change is shown correctly in phpinfo(), it has no effect.

Behaviour: all variables exceeding 1000 are ignored

tested in PHP 5.3.3-7+squeeze17 without suhosin module

A possible workaround: compact all form-data with javascript



回答3:

I think your problem is not the number of yourform fields, I think the total data you are sending is to much.

There is an php.ini directive that limits how much data you totally can send on a post request (check: post_max_size).

But you can not change post_max_size while runtime (because this value is checked before the first line of you php files during input phase of php).

Your have several ways to change this value:

  1. In Webserver Config
  2. in a htaccess file

with the following code:

php_value post_max_size 512M # set maximum post data to 512 MB
  1. in your global php.ini
  2. in your users.ini (if it's configured)

with the following code:

post_max_size = 512M