PHP max_input_vars
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10303714/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP max_input_vars
提问by user39653
I'm getting a max_input_varserror message.
我收到一条max_input_vars错误消息。
I understand there's a php.inisetting that can change this starting with version 5.3.9 however, I'm running version 5.1.6.
我知道有一个php.ini设置可以从 5.3.9 版开始更改此设置,但是,我运行的是 5.1.6 版。
When I view the configuration information for my 5.1.6 server it shows max_input_varsvalue is 1000.
当我查看 5.1.6 服务器的配置信息时,它显示max_input_vars值为 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.inifile. Does this mean that the value is hard coded in this version of PHP and can't be changed?
我的问题是:即使我运行的是 5.1.6,我也看到了这个设置,phpinfo()但它不在php.ini文件中。这是否意味着该值在此版本的 PHP 中是硬编码的并且无法更改?
采纳答案by Narf
You can add it to php.ini and it should work - just tested it on PHP 5.3.6.
您可以将它添加到 php.ini 并且它应该可以工作 - 刚刚在 PHP 5.3.6 上对其进行了测试。
回答by lubosdz
Reference on PHP net:
PHP网上参考:
http://php.net/manual/en/info.configuration.php#ini.max-input-vars
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.
请注意,您不能在运行时使用 function 设置此指令ini_set(name, newValue),例如
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).
如文档中所述,此指令只能按目录范围设置,这意味着通过 .htaccess 文件、httpd.conf 或 .user.ini(自 PHP 5.3 起)。
See http://php.net/manual/en/configuration.changes.modes.php
见http://php.net/manual/en/configuration.changes.modes.php
Adding the directive into php.ini or placing following lines into .htaccess will work:
将指令添加到 php.ini 或将以下行放入 .htaccess 将起作用:
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
回答by Vaughany
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 patchwhich Apache under Debian does.
刚刚在 5.3.3 中尝试了此修复程序,但没有任何变化。谷歌搜索我发现这个网页http://anothersysadmin.wordpress.com/2012/02/16/php-5-3-max_input_vars-and-big-forms/详细说明了如果您的服务器使用 Suhosin 补丁需要更改的其他设置Debian 下的 Apache 是做什么的。
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
因此,如果您想将此数字从默认数字 1000 增加到 3000,则必须在 php.ini 中添加以下几行:
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.
我测试了它(在/etc/php5/apache2和/etc/php5/cli中向php.ini添加了设置,并成功重新启动了Apache)但phpinfo中仍然没有max_input_vars变量。
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.
一些站点指出 PHP 5.3.9 作为此更改将采用的第一个 PHP 版本,所以我的错首先是没有正确 RTM,尽管我有兴趣看到人们报告它在 5.3.3 以上的版本中工作但低于 5.3.9。
回答by Oleg Sapishchuk
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%.
您需要在 php.ini 文件中取消注释 max_input_vars 值并增加它(exp. 2000),也不要忘记重新启动您的服务器,这将有助于 99,99%。
回答by nokieng
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_varsparam. because I only tried to restart apache2service, but not php fpm
现在是 2018 年。当我必须发送超过max_input_vars. 我想出了一个解决方案,像我这样的新手在更改max_input_vars参数后忘记重新启动 php fpm 服务。因为我只尝试重启apache2服务,而不是 php fpm
- uncomment code at
/etc/php/7.0/fpm/php.iniand set number as you wishmax_input_vars = 4000 - restart php fpm service, as I use php 7. Therefore,
sudo service php7.0-fpm restart
- 取消注释代码
/etc/php/7.0/fpm/php.ini并根据需要设置数字max_input_vars = 4000 - 重新启动 php fpm 服务,因为我使用的是 php 7。因此,
sudo service php7.0-fpm restart
Hope it helps
Tested on Debian Stretch, php7.0
希望它有助于
测试Debian Stretch,php7.0
回答by Luis Farfan
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.
使用此指令可以减少使用哈希冲突的拒绝服务攻击的可能性。如果输入变量多于此指令指定的数量,则会发出 E_WARNING,并从请求中截断更多输入变量。
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.
我可以建议不要扩展默认值 1000 并通过序列化请求或按块发送请求来扩展应用程序功能。否则,您可以将其扩展到所需的配置。
It definitely needs to set up in the php.ini
肯定需要在php.ini中设置
回答by Gary Samad
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.
请注意,您必须将其放在 Centos7 中的“.user.ini”文件中,而不是在 Centos6 中使用的“php.ini”文件中。您可以将“.user.ini”放在任何子目录中,以便仅影响该目录。
.user.ini :
.user.ini :
max_input_vars = 3000
Tested on Centos7 and PHP 5.6.33.
在 Centos7 和 PHP 5.6.33 上测试。
回答by Rahul K A
php_value max_input_vars 6000
php_value max_input_vars 6000
"Put this line on .htaccess file of your site. "
“将此行放在您网站的 .htaccess 文件中。”
回答by MagicMartinian
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
刚刚将菜单项添加到 Wordpress 时遇到了同样的问题。我在 Ubuntu 18.04、PHP 7.0 上使用 Wordpress 4.9.9。我只是取消了以下行的注释并将其增加到 1500/etc/php/7.0/apache2/php.ini
; How many GET/POST/COOKIE input variables may be accepted<br>
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.
希望有帮助。
回答by Patel Nikhil
"PHP message: PHP Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini.
“PHP 消息:PHP 警告:未知:输入变量超过 1000。要增加限制更改 php.ini 中的 max_input_vars。
This php configuration parameter max_input_vars will affect not only your GET / POST / COOKIES parameters it also controls your any Form Input.
这个 php 配置参数 max_input_vars 不仅会影响你的 GET / POST / COOKIES 参数,它还会控制你的任何表单输入。
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
1) 通过在您的 php.ini 文件中查看现有设置/值来检查它使用定位 php.ini 文件
<?php echo getinfo(); ?>
<?php echo getinfo(); ?>
find below key: Loaded Configuration File : /etc/php/5.6/fpm/php.ini
找到以下键:加载的配置文件:/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.
2) 在可编辑模式下打开 php.ini 文件并搜索 max_input_vars 这行可能在你现有的默认设置中被注释,默认值为 1000 ,所以删除; 取消注释并使用合适的值对其进行编辑,例如 2500。
3) Save the file and Restart the Services of PHP by using below
sudo service php5.6-fpm restart
3) 使用下面的方法保存文件并重启 PHP 服务
sudo service php5.6-fpm restart
Similarly you can update any other similar PHP Configuration to your ease.
同样,您可以轻松地更新任何其他类似的 PHP 配置。

