PHP max_input_vars
You can add it to php.ini and it should work - just tested it on PHP 5.3.6.
How to change max_input_vars
ASH's suggested
ini_set('max_input_vars','2000' );
but this never work with ini_set.
You need to set it with php.ini or .htaccess file only.
Increase PHP max_input_vars via web.config in IIS
There are four modes in which the PHP directives can be set:
- PHP_INI_USER
- PHP_INI_PERDIR
- PHP_INI_SYSTEM
- PHP_INI_ALL
Please have a look at how these are managed: http://www.php.net/manual/en/configuration.changes.modes.php
Each directive has one of these changeability modes defined and for that you could visit: http://www.php.net/manual/en/ini.list.php
As you'd see, the changeability attribute for directive max_input_vars
is PHP_INI_PERDIR
, meaning it can be overridden by adding a custom value in either of php.ini
, .htaccess
, httpd.conf
(Apache) or .user.ini
. Therefore, defining a new php.ini
file to increase the limit of max_input_vars
is just as fine as the other three workarounds.
Please remember though that, at times, some of the extensions that PHP would use might need to be re-enabled in custom ini
files. For instance, I've at times run into problems with pdo
and mysqli
being considered as disabled, unless explicitly set in the custom file too, when using an override ini
file.
Hitting the limit on php's max_input_vars - But don't know why
Each array element is it's own variable sent as, for a single dimension:
array1%5B%5D=1 & array1%5B%5D=1
And for two dimensions:
array1%5B1%5D%5B0%5D=1 & array1%5B2%5D%5B0%5D=1
So array1[999][999]
WILL violate max_input_vars
if set at 1000, because array1[0][0]
thorough array1[0][999]
is 1000 variables. In this case, adding array1[1][0]
will put it over 1000 and generate:
Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0
max_input_vars set even if commented in php.ini
According to the manual, there is indeed a default value of 1000
for max_input_vars
(look in the table at the beginning of the page).
If you want a value different than this default value of 1000, you will have to specify it -- and not comment the directive in your configuration.
As far as I can tell, there is no way to make max_input_vars
unlimited ; you could set it to a high enough value, of course, but remember that this directive has been added recently as a security measure. Also, it doesn't make sense to set the max_input_vars
to unlimited since then a malicious user could send a huge load of data and exhaust your memory.
Can't change max_input_vars limit in php.ini
As you're using PHP-FPM, you need to check it's configs for overrides, typically in /etc/php-fpm/*.conf
.
php_admin_value[max_input_vars] = XXX
After validating there are no overrides that affect your settings, restart the php-fpm service and as a best-practice also Apache.
systemctl restart php-fpm httpd
Restarting the PHP-FPM service is required because Apache passes requests to the running PHP instance(s) loaded into memory from the PHP-FPM service. As PHP is already loaded into memory by PHP-FPM, the PHP-FPM service needs to be restarted for PHP configuration changes to be applied.
Apache prior to PHP-FPM typically relied on starting the PHP process using the Apache mod_php
, thereby requiring the restarting of the Apache service for configuration changes to be applied immediately, or until mod_php
reloaded the PHP instance.
Based on your configuration, you should add additional PHP config settings to /etc/php.d/zzz-custom.ini
instead of /etc/php.ini
. PHP will load the config files in alphabetical order, resulting in the zzz-custom.ini
file being loaded last and be used as the final values of the PHP settings.
Using the /etc/php.d/zzz-custom.ini
file will also prevent the loss of your custom php.ini settings and the need to make extensive changes to the default /etc/php.ini
file when updating PHP versions.
However, /etc/php-fpm/*.conf
settings will take precedent over any /etc/php.d/*.ini
configs.
Related Topics
Return Index of Highest Value in an Array
Laravel Eloquent Select All Rows With Max Created_At
Maximum Execution Time in PHPmyadmin
Warning: Domdocument::Loadhtml(): Htmlparseentityref: Expecting ';' in Entity,
Laravel 5 - Clear Cache in Shared Hosting Server
PHP: Sort and Count Instances of Words in a Given String
PHP Convert Date Format Dd/Mm/Yyyy =≫ Yyyy-Mm-Dd
What Are PHP Nested Functions For
Wamp Cannot Access on Local Network 403 Forbidden
What Do I Need to Store in the PHP Session When User Logged In
Merging Arrays With the Same Keys