使用 ini_set 设置 max_input_vars PHP.ini 指令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9973555/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 08:01:04  来源:igfitidea点击:

setting max_input_vars PHP.ini directive using ini_set

phpphp-ini

提问by crmpicco

Can I set the max_input_vars PHP.ini directive in my code? I have it set at the default 1000, however I have a script that has many checkboxes and text fields that could, and quite possibly will, go over the 1000 limit.

我可以在我的代码中设置 max_input_vars PHP.ini 指令吗?我将它设置为默认 1000,但是我有一个脚本,其中包含许多复选框和文本字段,它们可能并且很可能会超过 1000 的限制。

I'm using PHP 5.3.10 and i'm not getting any errors doing this. Also, I can't find any documentation that states I can't do this.

我使用的是 PHP 5.3.10 并且我没有遇到任何错误。另外,我找不到任何说明我不能这样做的文档。

ini_set('max_input_vars', 3000);

Thanks.

谢谢。

回答by pjumble

max_input_varshas a changeable mode of PHP_INI_PERDIRmeaning it can't be changed using ini_set(only in php.ini, .htaccess or httpd.conf)

max_input_vars有一个可变模式PHP_INI_PERDIR意味着它不能使用ini_set(仅在 php.ini、.htaccess 或 httpd.conf 中)进行更改

回答by Omari Victor Omosa

I know many people avoid accessing php.inidue to one reason or the other. so another way would be to create a .htaccessfile in the operation folder and add the following codes and set the values to a higher value. Just add them directly no need to initialize anything in the .htaccessfile

我知道很多人php.ini由于某种原因而避免访问。所以另一种方法是.htaccess在操作文件夹中创建一个文件并添加以下代码并将值设置为更高的值。直接添加即可,无需初始化.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

This solution worked for me without accessing the php.inifile. since some of the web host providers give us a hard time when we want to access the php.inifile

这个解决方案对我有用,而无需访问php.ini文件。因为当我们想要访问php.ini文件时,一些网络主机提供商给我们带来了困难