PHP max_input_vars

04/24/2020 23:00:02

I'm getting a max_input_vars error message.

I understand there's a php.ini setting that can change this starting with version 5.3.9 however, I'm running version 5.1.6.

When I view the configuration information for my 5.1.6 server it shows max_input_vars value is 1000.

My question is: Even though I'm running 5.1.6, I see this setting from phpinfo() but it's not in the php.ini file. Does this mean that the value is hard coded in this version of PHP and can't be changed?

Verified Answer (45 Votes)

04/24/2012 23:32:41

You can add it to php.ini and it should work - just tested it on PHP 5.3.6.


Answer #2 (97 Votes)

01/05/2013 04:12:46

Reference on PHP net:

Please note, you cannot set this directive in run-time with function ini_set(name, newValue), e.g.

ini_set('max_input_vars', 3000);

It will not work.

As explained in documentation, this directive may only be set per directory scope, which means via .htaccess file, httpd.conf or .user.ini (since PHP 5.3).


Adding the directive into php.ini or placing following lines into .htaccess will work:

php_value max_input_vars 3000
php_value suhosin.get.max_vars 3000
php_value 3000
php_value suhosin.request.max_vars 3000

Answer #3 (20 Votes)

07/05/2012 12:52:03

Have just attempted this fix with 5.3.3 and there's no change. Googling around I found this web page detailing other settings which need changing if your server uses the Suhosin patch which Apache under Debian does.

The site explains:

So, if you want to increase this number to, say, 3000 from the default number which is 1000, you have to put in your php.ini these lines:

max_input_vars = 3000 = 3000 suhosin.request.max_vars = 3000

I tested it (added settings to php.ini both in /etc/php5/apache2 and /etc/php5/cli, and restarted Apache successfully) but still no max_input_vars variable in phpinfo.

A few sites point to PHP 5.3.9 as the first PHP version in which this change will take, so my fault for not RTM properly in the first place, although I'm interested to see people reporting it working in version above 5.3.3 but below 5.3.9.

Hack Hex uses Stack Exchance API by the Stack Exchange Inc. to scrape questions/answers under Creative Commons license.