PHP限制在POST变量 [英] PHP Limit in POST variables

查看:199
本文介绍了PHP限制在POST变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个数组发送到通过POST方法的PHP脚本。首先,我的连载(),然后用 base64_en code()就可以了。 receving它后,脚本和 base64_de code()这和反序列化()它。我知道,使用base64_en code函数由33%增加了数据的大小,所以我很担心,POST变量可能不堪重负,从而给了我一个错误。有一个字符串的限制,可以POST'ed?或者更好的,有没有我可以用比base64_en code等对数组正确地传递给其他脚本的另一种方式?顺便说一句,不使用base64_功能的系列化,我得到的错误:..偏移的通知。

I'm trying to send an array to a PHP script via POST method. First I serialize() it, then used base64_encode() on it. After receving it, the script then base64_decode() it then unserialize() it. I know that using base64_encode functions increases the data size by 33%, so I'm worried that the POST variables might be overwhelmed, and thus giving me an error. Is there a limit to a string that can be POST'ed? Or better, is there another way that I can use other than base64_encode to correctly pass the array to the other script? By the way, without using base64_ functions on serialization, I get the "Error:.. offset" notice.

推荐答案

这将取决于该阵列的内容。如果是主要是文本,那么你可以COM preSS / DECOM preSS使用gzcom preSS / gzuncom preSS生成的序列化对象:

It would depend on the contents of the array. If it is mostly text, then you could compress/decompress using gzcompress/gzuncompress the resulting serialized object:

$encoded = base64_encode(gzcompress(serialize($original)));

$original = unserialize(gzuncompress(base64_decode($_POST['encoded'])));

gzen code / gzde code可能会提供更好的融为一体pression对于较大规模的数据。如果您的阿雷包含二进制数据,甚至更糟糕的COM pressed数据,那么这种方法可能不会获得太多如果有的话。

gzencode/gzdecode will probably give better compression for larger size data. If your aray contains binary data, or even worse compressed data, then this technique will probably not gain much if anything.

除了已经提到的PHP配置,Web服务器还可以限制POST大小限制,比如LimitRequestBody指令中的Apache:的 http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestbody

In addition to the PHP configuration already mentioned, your web server can also impose POST size limits, for instance the LimitRequestBody directive in apache: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestbody

这篇关于PHP限制在POST变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆