How to Change the Maximum Number of Input Variables for PHP Scripts

0
308
Number of Input Variables for PHP Scripts

Simply stated, PHP max input vars is the number of variables your server is set to handle in each function. The PHP max input vars were introduced in PHP 5.3.9+ as a security measure to limit the submission of the maximum amount of POST variables.  

It depicts 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 PHP max input vars error.

In case of receiving the error ‘Increase PHP Max Input Vars Limit’ in WordPress, you need to add the code ‘php_value max_input_vars 3000′ to your .htaccess file. 

In this KB, we will explain to you how to do this, we will discuss all the possibilities in cPanel and explain how to change the PHP max input vars for your entire web hosting account in order to fit specific applications requirements. But before that, we will explain your what PHP Input vars is.

How to Increase PHP Max Input Vars Limit?

Here, we will explain to you different methods to increase the PHP max input vars limit. You can escalate the PHP Max Input Vars Limit by summing up lines to the .htaccess file, php.ini or wp-config.php. But before that learn about What is PHP Inpur Var.

What are PHP Input Vars?

The PHP max input var value represents for a single function how many variables your server can use to avoid overloads. For Instance, this value is set to 3000 for updated and modern WordPress themes. This value depends on your script or website, you may need to change this value.

Although the default value for max_input_vars should be enough, otherwise you may receive the error ‘Increase PHP max input vars Limit’. If the PHP developer has created a bulk editing or functionality processing task. The limit can easily be attained.

This error can cause various issues in 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 you may lose template functionality. Additionally, the activated widgets on your website may disappear.

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

Edit the .htaccess File

The first method to increase PHP max input var limitation is by editing the .htaccess file. Before making any modifications to the file, make certain you get a backup of your site.

Usually, this file is present in the root directory of your host. In case, if you can’t find it, that means this (.) file is hidden. As, most hosting providers hide the (.) files. Therefore, in your configuration, enable the option of Show Hidden Files.

After that, open the editor window and open the .htaccess file and then add the following code to it:

php_value max_input_vars 3000

or for Suhosin users, add the following to the file:

php_value suhosin.request.max_vars 3000

php_value suhosin.post.max_vars 3000

The recommended value for PHP input vars is 3000. In case you need more; you could always escalate it to match your requirements.

Edit the PHP.ini file

There is another method to escalate the PHP max input vars limit through editing the php.ini file in WordPress. This file is also available in the root directory of your host where you have installed WordPress. In case, if you can’t find it, simply, create a php.ini file.

In both the above cases, you need to open the editor window to open the file and then add the following code to it:

max_input_vars = 3000


Once you made the changes,  don’t forget to reboot your server. So that without any hindrance you can use the newly added data.

Edit the wp-config.php File

This method needs to log in to your hosting panel or FTP. For that, you need to go to File Manager and navigate for the wp-config.php file. 

Once you navigate, open the file in an editor window and add the following code to it:

@ini_set( ‘max_input_vars’ , 3000 );

Finally, save the changes.

You can replace this 3000 value with any required value. However, we recommend 3000 or above, if you use any value below 3000, it could cause the PHP max input vars error.

How to Increase the PHP5 Max Input Vars Limit?

If you are using a host that still uses PHP5, you need to edit php5.ini and user.ini files.

So, if you are still using a host that uses PHP5, you need to build the files mentioned above in the host. Once the files created, you need to copy and paste the following code to both:

max_input_vars = 3000

suhosin.get.max_vars = 3000

suhosin.post.max_vars = 3000

suhosin.request.max_vars = 3000

Again, you can replace 3000 with the value of your website requirements.

Conclusion

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

Hence, if you are getting the same error message, again and again, the suggested tips do not resolve your issue. In that case, please contact our technical support team as they will investigate and surely resolve this issue for you.