在PHP中,如何检测输入变量是否因超过max_input_vars而被截断?(In PHP, how can I detect that input vars were truncated due to max_input_vars being exceeded?)
我知道E_WARNING是由PHP生成的
PHP警告:未知:输入变量超过1000
但是我如何在脚本中检测到这一点?
I know that an E_WARNING is generated by PHP
PHP Warning: Unknown: Input variables exceeded 1000
But how can I detect this in my script?
最满意答案
一个“足够接近”的方法是检查if( count($_POST, COUNT_RECURSIVE) == ini_get("max_input_vars"))
如果POST变量的数量恰好处于极限,这将导致误报,但考虑到默认限制为1000,则不太可能成为问题。
A "close enough" method would be to check if( count($_POST, COUNT_RECURSIVE) == ini_get("max_input_vars"))
This will cause a false positive if the number of POST vars happens to be exactly on the limit, but considering the default limit is 1000 it's unlikely to ever be a concern.
更多推荐
发布评论