Query variable can be no longer than 512 characters

孤人 提交于 2019-12-02 07:19:58

问题


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.

Example:

# 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>
?>

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?


回答1:


There is a PHP bug report. #50449

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

It says there that it is Suhosin causing the behaviour.



来源:https://stackoverflow.com/questions/4133536/query-variable-can-be-no-longer-than-512-characters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!