What is max_input_vars in php ini?

How to change the maximum number of input variables for PHP scripts

This article describes how to change the maximum number of input variables allowed for PHP scripts by using the max_input_vars directive in a php.ini file.

The information in this article only applies to certain types of hosting accounts. To determine whether or not the information below applies to your account, please see this article.

This article assumes that you have already set up a custom php.ini file on your web site. If you have not already set up a custom php.ini file, please read this article first.

Using the max_input_vars directive

PHP obtains input variables from HTML forms (through GET and POST requests), as well as from any cookies enabled on a page. By default, the maximum number of input variables allowed for PHP scripts is set to 1000. You can change this amount by setting the max_input_vars directive in a php.ini file.

To change the maximum number of input variables allowed, use a text editor to add the max_input_vars directive to your php.ini file. For example, to set the maximum number of input variables to 1500, add the following setting:

max_input_vars = 1500

To verify the current value of the max_input_vars directive and other directives, you can use the phpinfo() function. For more information, please see this article.

More Information

  • To view a complete list of php.ini directives, please visit http://www.php.net/manual/en/ini.list.php.
  • For more information about the max_input_vars directive, please visit http://www.php.net/manual/en/info.configuration.php#ini.max-input-vars.

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?

zessx

67.1k28 gold badges131 silver badges155 bronze badges

asked Apr 24, 2012 at 18:18

9

Reference on PHP net:

http://php.net/manual/en/info.configuration.php#ini.max-input-vars

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).

See http://php.net/manual/en/configuration.changes.modes.php

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 suhosin.post.max_vars 3000
php_value suhosin.request.max_vars 3000

answered Jan 4, 2013 at 23:12

lubosdzlubosdz

3,9922 gold badges28 silver badges40 bronze badges

5

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

answered Apr 24, 2012 at 18:32

NarfNarf

14.4k3 gold badges36 silver badges65 bronze badges

3

Have just attempted this fix with 5.3.3 and there's no change. Googling around I found this web page http://anothersysadmin.wordpress.com/2012/02/16/php-5-3-max_input_vars-and-big-forms/ 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 suhosin.post.max_vars = 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.

answered Jul 5, 2012 at 7:52

VaughanyVaughany

95314 silver badges21 bronze badges

1

It's 2018 now.And I just got stuck on this problem when I must send a request that exceeds the max_input_vars. And I came up with a solution that newie like me forgot to restart php fpm service after changing the max_input_vars param. because I only tried to restart apache2 service, but not php fpm

  1. uncomment code at /etc/php/7.0/fpm/php.ini and set number as you wish
    max_input_vars = 4000
  2. restart php fpm service, as I use php 7. Therefore,
    sudo service php7.0-fpm restart

Hope it helps
Tested on Debian Stretch, php7.0

answered Feb 20, 2018 at 17:10

What is max_input_vars in php ini?

nokiengnokieng

1,67219 silver badges21 bronze badges

2

You need to uncomment max_input_vars value in php.ini file and increase it (exp. 2000), also dont forget to restart your server this will help for 99,99%.

answered Apr 30, 2014 at 8:47

What is max_input_vars in php ini?

3

Use of this directive mitigates the possibility of denial of service attacks which use hash collisions. If there are more input variables than specified by this directive, an E_WARNING is issued, and further input variables are truncated from the request.

I can suggest not to extend the default value which is 1000 and extend the application functionality by serialising the request or send the request by blocks. Otherwise, you can extend this to configuration needed.

It definitely needs to set up in the php.ini

answered Sep 8, 2016 at 12:57

Note that you must put this in the file ".user.ini" in Centos7 rather than "php.ini" which used to work in Centos6. You can put ".user.ini" in any subdirectory in order to affect only that directory.

.user.ini :

max_input_vars = 3000

Tested on Centos7 and PHP 5.6.33.

answered Feb 20, 2018 at 6:07

Gary SamadGary Samad

7635 silver badges14 bronze badges

php_value max_input_vars 6000

"Put this line on .htaccess file of your site. "

answered May 2, 2018 at 9:54

What is max_input_vars in php ini?

Rahul K ARahul K A

3023 silver badges4 bronze badges

1

Just had the same problem adding menu items to Wordpress. I am using Wordpress 4.9.9 on Ubuntu 18.04, PHP 7.0. I simply uncommented the following line and increased it to 1500 in /etc/php/7.0/apache2/php.ini

; How many GET/POST/COOKIE input variables may be accepted
max_input_vars = 1500

Then used the following to effect the change:

sudo apache2ctl configtest  #(if it does not return ok Apache will not start)
sudo service apache2 reload

Hope that helps.

atline

24.7k16 gold badges59 silver badges93 bronze badges

answered Jan 21, 2019 at 6:46

"PHP message: PHP Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini.

This php configuration parameter max_input_vars will affect not only your GET / POST / COOKIES parameters it also controls your any Form Input.

To set or change its value follow the below steps.

1) check the existing setting / value by viewing it in your php.ini file Locate php.ini file by using

find below key: Loaded Configuration File : /etc/php/5.6/fpm/php.ini

2) Open the php.ini file in editable mode and do search for max_input_vars This line may be commented in your existing default setting with default value of 1000 , So remove ; to uncomment it and Edit it with your suitable value e.g. 2500.

3) Save the file and Restart the Services of PHP by using below sudo service php5.6-fpm restart

Similarly you can update any other similar PHP Configuration to your ease.

answered Aug 28, 2019 at 7:28

Just to complement. On a shared server using mod_suphp I was having the same issue.

Declaring 4 max_input_vars (suhosin included), didn't solved it, it just kept truncating on 1000 vars (default), and declaring "php_value max_input_vars 6000" on .htaccess threw error 500.

What solved it was to add the following on .htaccess, which applies the php.ini file recursively to that path

suPHP_ConfigPath /home/myuser/public_html

answered Dec 24, 2019 at 13:32

What is max_input_vars in php ini?

If you are using something like wodby (docker4php or docker4drupal) or lando or trying to find an answer "why php.ini doesn't work" (like me), these tools are using their own way to pass configuration into php

https://github.com/wodby/php#php-and-php-fpm-configuration

I was trying to set max_input_vars, in wodby+docker-compose you do it like so

  php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:
      PHP_MAX_INPUT_VARS: 9999

answered Dec 30, 2021 at 17:13

mevsmemevsme

3701 silver badge13 bronze badges

New Cpanels block to see the .htaccess file or if you add a .user.ini you wont be able to see it. but with a little hack you can make it work. Edit for example wp-config.php and in the URL bar replace wp-config.php by .htaccess now you can paste the values and save it. enter image description here

answered Mar 29, 2018 at 22:10

What is max_input_vars in php ini?

Yes, add it to the php.ini, restart apache and it should work.

You can test it on the fly if you want to with ini_set("max_input_vars",100)

IluTov

6,6756 gold badges37 silver badges99 bronze badges

answered Apr 24, 2012 at 18:47

QuaidQuaid

2331 silver badge7 bronze badges

3

What is the use of max_input_vars?

Using the max_input_vars directive PHP obtains input variables from HTML forms (through GET and POST requests), as well as from any cookies enabled on a page. By default, the maximum number of input variables allowed for PHP scripts is set to 1000.

How do I change the maximum vars in PHP?

1 Method: edit the PHP..
Locate your PHP. ini file. ... .
If you find your existing PHP. ini, open the file and locate the following line of code (xx represents a number): max_input_vars = xx ; And set it to your desired limit. ... .
If you created your own PHP. ... .
Save your changes, and reboot your local host or your server..

What is Max input vars?

The Max Input Var value represents how many variables for a single function your server can use to avoid overloads. Depending on your script or website, you may need to change this value. Although the default value for max_input_vars is usually enough, you may receive the error 'Increase PHP Max Input Vars Limit'.

How do you increase max input variables?

Max Input Vars can easily get increased by using a line of code. PHP max input vars is simply the number of variables your server is set to handle in each function. If you receive the error 'Increase PHP Max Input Vars Limit' in WordPress, you need to add the code 'php_value max_input_vars 3000' to your .