查询变量不能超过512个字符 [英] Query variable can be no longer than 512 characters
问题描述
我正在努力读取$_GET
数组中包含超过512个字符的查询变量.但是,如果我使用parse_string
解析查询字符串,则可以从结果数组中很好地读取它.
I'm struggling to read query variables that contain more than 512 characters in the $_GET
array. If I parse the query string using parse_string
, however, I can read it just fine from the resulting array.
示例:
# GET /test.php?foo=<string with 513 characters>&bar=bar HTTP/1.1
<?php
var_dump($_GET['foo']); # NULL
var_dump($_GET['bar']); # "bar"
parse_str($_SERVER['QUERY_STRING'], $output);
var_dump($output['foo']); # <string with 513 characters>
?>
这对我来说毫无意义,因为$_GET
在内部使用parse_str
从查询字符串中派生查询变量.我想念什么吗?
This makes no sense to me, since $_GET
uses parse_str
internally to derive the query variables from the query string. Am I missing something?
推荐答案
有一个PHP错误报告. #50449
There is a PHP bug report. #50449
GET参数的值超过512个字符不会显示在 $ _GET和$ _REQUEST数组.自升级到 5.3.1
GET parameters with a value longer than 512 characters don't show up in the $_GET and $_REQUEST arrays. We've noticed this since upgrading to 5.3.1
它说那里是Suhosin引起的行为.
It says there that it is Suhosin causing the behaviour.
这篇关于查询变量不能超过512个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!