PHP max_input_vars Explained: Configuration, Limits, and Best Practices
Introduction
The max_input_vars directive defines the maximum number of input variables that PHP accepts in a single request. These input variables include values submitted through HTML forms using the $_GET, $_POST, and $_COOKIE superglobals.
When a request contains more variables than the configured limit, PHP silently discards the remaining variables. This may result in incomplete form submissions, missing configuration values, or unexpected application behavior.
This guide explains how max_input_vars works, how to configure it, recommended values for different applications, and common issues caused by reaching the input variable limit.
Test Environment
What Is max_input_vars?
The max_input_vars directive limits the number of input variables that PHP processes in a single request.
Example:
This means PHP processes up to 1,000 input variables.
Any variables beyond this limit are ignored.
How max_input_vars Works
Suppose a user submits a large HTML form.
As a result, some submitted values never reach the PHP application.
Check the Current Value
Run:
Example output:
max_input_vars => 1000 => 1000
Locate the Active php.ini File
Example:
Loaded Configuration File: /etc/php.ini
If your website uses PHP-FPM, ensure you modify the configuration file used by PHP-FPM.
Change max_input_vars
Open the PHP configuration file.
Locate:
max_input_vars = 1000
Increase the value if necessary.
Example:
max_input_vars = 3000
Save the file.
Restart PHP-FPM
Apply the new configuration.
Verify the service status.
Expected output:
Active: active (running)
Verify the Configuration
Run:
Or use:
Search for:
max_input_vars
The displayed value should match the updated configuration.
Recommended Values
Only increase the limit when your application genuinely requires a larger number of form fields.
Common Warning
PHP may log a warning similar to:
PHP Warning:
Input variables exceeded 1000.
To increase the limit change max_input_vars in php.ini.
Although the application may continue running, some submitted values will be missing.
Common Issues
WordPress Menus Are Not Saved
Large navigation menus can exceed the default limit of 1000 variables.
Increasing max_input_vars usually resolves the issue.
Missing Form Data
If some form fields disappear after submission, check whether the total number of submitted variables exceeds the configured limit.
WooCommerce Product Attributes Missing
Stores with many product variations and attributes can easily exceed the default limit, resulting in incomplete product data being saved.
max_input_vars vs Other PHP Limits
Each directive controls a different aspect of request processing.
Increasing post_max_size or memory_limit does not increase the number of input variables PHP accepts.
Best Practices
Keep the default value if your application works correctly.
Increase the limit only for applications with large forms.
Restart PHP-FPM after modifying the configuration.
Verify the new value using phpinfo() or php -i.
Test complex forms after changing the configuration.
Conclusion
The max_input_vars directive limits the number of input variables PHP processes in a single request. While the default value is sufficient for many websites, applications with large forms, extensive WordPress menus, or complex WooCommerce products often require a higher limit.
When troubleshooting incomplete form submissions, checking max_input_vars is just as important as reviewing post_max_size and upload_max_filesize.
Explore More
› PHP max_file_uploads Explained: Configuration, Limits, and Best Practices
› PHP upload_max_filesize Explained: Configuration, Limits, and Best Practices
› PHP post_max_size Explained: Configuration, Limits, and Best Practices
› PHP opcache.max_accelerated_files Explained: Configuration, Performance, and Best Practices