问题
I've got a pretty long query string variable (value is approximately 600 chars) that I'm trying to reach from a PHP script. The long one is not present in $_REQUEST
or $_GET
but another variable with shorter value length is. I've shaved off some of it to test and it starts going missing when the value is at 549 chars or more.
Fortunately the long variable is present in $_SERVER["QUERY_STRING"]
so for now I'm just picking it up from there, but was curious as to if this is a server setting (Apache 2) or something with my PHP setup (5.2.17) or script?
BTW, the query string itself is not something I control so unfortunately I can't change how that works, for ex. sending via POST.
回答1:
Maybe you have a hardend/suhosin version of php. It provides configuration directives to limit the length of names and values for input parameters.
suhosin.get.max_name_length
Type: Integer Default: 64Defines the maximum length of variable names for variables registered through the URL. For array variables this is the name in front of the indices.suhosin.get.max_totalname_length
Type: Integer Default: 256Defines the maximum length of the total variable name when registered through the URL. For array variables this includes all indices.suhosin.get.max_value_length
Type: Integer Default: 512Defines the maximum length of a variable that is registered through the URL.
回答2:
I just ran into this in PHP 5.4 in Debian Wheezy, which does not use suhosin. I finally found this user note buried on the parse_str() page that max_input_vars
in php.ini setting controls the number of variables parse_str()
will read in this version of PHP.
Also note that max_input_vars
applies even if you are using the CLI runtime.
来源:https://stackoverflow.com/questions/8485908/long-query-string-variable-missing