Supposed I'm receiving an HTTP request. I try to access it, but because it has lots and lots of data, PHP's max_input_vars
directive effectively cuts some of the parameters from request: When I try to access the request using e.g. $_REQUEST
, some of the data is missing. How do I know when this happens?
For some background:
I know I can get count($_REQUEST)
and compare it to the value returned by ini_get('max_input_vars')
, but I would like to write foolproof code where I can detect exceeding the limit by even one. Another drawback of this method is that when passing lists etc., each list element becomes a separate request parameter that counts towards the limit, but PHP parses them into a single array again. For example, something like list = [1, 2, 3]
is passed as something like this in the request:
list[]=1
list[]=2
list[]=3
After PHP parses this into, say, $_REQUEST
, it's a single array (i.e. $_REQUEST['list']
) again, which causes count($_REQUEST)
to not return the wanted value. It's possible to get around this but it's not the most convenient thing to do.