php _GET 中 URL 参数的最大大小

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

Max size of URL parameters in _GET

php

提问by alexfernandez

I am accessing a PHP server using REST: all data is passed in a GET request as URL parameters. One of the parameters arrives at the server in the query_string, but it is not in the _GET global. But shortening the parameter (the cutoff seems to be around 512 characters) lets it through.

我正在使用 REST 访问 PHP 服务器:所有数据都作为 URL 参数在 GET 请求中传递。其中一个参数在 query_string 中到达服务器,但它不在 _GET 全局中。但是缩短参数(截止值似乎在 512 个字符左右)可以让它通过。

Assuming I have diagnosed the problem correctly, is there a way to change this maximum size? I have not found any explanation in the documentation, not even a mention of this limit. This is on Debian squeeze / Apache 2.2.16 / PHP 5.3.3.

假设我已经正确诊断了问题,有没有办法改变这个最大大小?我在文档中没有找到任何解释,甚至没有提到这个限制。这是在 Debian 挤压 / Apache 2.2.16 / PHP 5.3.3 上。

回答by Karolis

Ok, it seems that some versions of PHP have a limitation of length of GET params:

好吧,似乎某些版本的 PHP 对 GET 参数的长度有限制:

Please note that PHP setups with the suhosin patch installed will have a default limit of 512 characters for get parameters. Although bad practice, most browsers (including IE) supports URLs up to around 2000 characters, while Apache has a default of 8000.

To add support for long parameters with suhosin, add suhosin.get.max_value_length = <limit>in php.ini

请注意,安装了 suhosin 补丁的 PHP 设置对于 get 参数的默认限制为 512 个字符。尽管这是不好的做法,但大多数浏览器(包括 IE)支持最多 2000 个字符的 URL,而 Apache 的默认值为 8000。

要添加使用了Suhosin长参数的支持,加上 suhosin.get.max_value_length = <limit>php.ini

Source: http://www.php.net/manual/en/reserved.variables.get.php#101469

来源:http: //www.php.net/manual/en/reserved.variables.get.php#101469

回答by Geoffroy

See What is the maximum length of a URL in different browsers?

请参阅不同浏览器中 URL 的最大长度是多少?

The length of the url can't be changed in PHP. The linked question is about the URL size limit, you will find what you want.

无法在 PHP 中更改 url 的长度。链接的问题是关于 URL 大小限制,你会找到你想要的。