How do i change the maximum number of input variables in a php script?

The PHP variable max_input_vars was introduced in PHP 5.3.9+ as a security measure to limit the maximum amount of POST variables submitted. It represents the number of variables your server can use to run a function. If the value of PHP input vars is not enough, you will get the max_input_vars error.

To resolve this, the default value can be increased. In this post, we will discuss all the possibilities in cPanel and explain how to change the maximum number of input variables allowed for PHP scripts for your entire web hosting account in order to fit specific application requirements. 

  • What is the PHP Input Vars?
  • How to Increase PHP Max Input Vars Limit?
    • Option 1: Use the “Select PHP Version” Tool in cPanel
    • Option 2: Edit the .htaccess File

What is the PHP Input Vars?

Before we dive into the methods to increase PHP Max Input Vars, let us cover what exactly is PHP 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’. The limit can easily be reached if the PHP developer has created a bulk editing/processing functionality.

This error can cause a lot of issues on your website's performance, as well as cause issues with your Plugins or Theme. For example, you may lose all of your data in your theme options or the template you are using may lose its functionality. In addition, the activated widgets on your website may disappear.

Note: This issue was addressed in WordPress 4.5 and above. If you’re not running the latest version of WordPress, we highly recommend upgrading instead of performing the described changes below.

How to Increase PHP Max Input Vars Limit?

There are many different methods to increase the PHP Max Input Vars. Setting the limit for the input variables can be done both automatically from the PHP selector in cPanel, or by using the File Manager or an FTP client and editing the .htaccess file.

Option 1: Use the “Select PHP Version” Tool in cPanel

This is the easiest method for setting the limit of input variables for your entire hosting account. All you have to do is:

  • Log into your cPanel;
  • Find and click on the 'Select PHP Version' under the 'Software' section:

How do i change the maximum number of input variables in a php script?

  • Once you’re inside, click on 'Switch to PHP Options':

How do i change the maximum number of input variables in a php script?

  • After switching, scroll down and you will see the max_input_vars with a drop-down right beside it. Use the drop-down to set your desired limit.

How do i change the maximum number of input variables in a php script?

Option 2: Edit the .htaccess File

As a second and preferred option, you can set the max_input_vars per application. In this example, we will use the cPanel File Manager, but you can do it via an FTP Client like FileZilla as well. Follow these steps:

  • Log into your cPanel;
  • Locate File Manager, which is under the ‘Files’ section:

How do i change the maximum number of input variables in a php script?

  • Once inside the File Manager, click on ‘Settings’ at the top-right corner, and then enable Show Hidden Files (dotfiles):

How do i change the maximum number of input variables in a php script?

  • After you do that, locate the .htaccess file of your desired application.
  • Select the .htaccess file, and click the right mouse button over it. Select ‘Edit’, and after you get a pop-up window, click on the button ‘Edit’ again to confirm:

How do i change the maximum number of input variables in a php script?

  • Once inside the .htaccess file, you need to add the following line at the end or beginning of the file:
    php_value max_input_vars 3000
    Where 3000 stands for your variable limit, and it should be what the specific application is requiring. If it’s WordPress, 3000 should be enough for any occasion.

Conclusion

The max_input_vars variable should be as lowest as possible as if it is greater one it opens the door to abusive behavior mostly with DDoS attacks hash collisions. This is the reason why we keep that variable lower on all our shared hosting plans.

If you are getting the same error message and the suggested fix does not resolve the issue for you please contact our technical support team as they will investigate and surely resolve this issue for you.

We hope you find this article useful. Discover more about FastCloud - the top-rated Hosting Solutions for personal and small business websites in four consecutive years by the HostAdvice Community!

How do you change the max input variables?

How to Increase the Max Input Vars Limit.
In your WordPress root installation locate any of these .htaccess , php.ini , .user.ini or wp-config.php..
Edit the file and paste the directive code..
Once you are done making changes save the file..

How do you increase the maximum input vars limit?

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 .

How increase PHP max input variables cPanel?

How to increase the max_input_vars limit in cPanel.
1) Log into cPanel..
2) Look for the SOFTWARE section and click on Select PHP version..
3) In the new window click on the Switch To PHP Options button..
4) Here you can locate the max_input_vars and enter the value that you require..

How do you fix PHP setting max_input_vars must be at least 5000?

If you created your own PHP. ini file, then add the same code inside it: max_input_vars = 5000 Simply change the value to the recommended value. For example, 5000. Save your changes, and reboot your localhost or your server.