php PHP中数组的最大大小是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6856506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:28:31  来源:igfitidea点击:

What is the maximum size of an array in PHP?

phparrays

提问by Amruta

We like to store database values in array. But we do not know the maximum size of an array which is allowed in PHP?

我们喜欢将数据库值存储在数组中。但是我们不知道 PHP 中允许的数组的最大大小?

回答by Tim

There is no max on the limit of an array. There is a limit on the amount of memory your script can use. This can be changed in the 'memory_limit' in your php.ini configuration.

数组的极限没有最大值。您的脚本可以使用的内存量是有限制的。这可以在 php.ini 配置中的“memory_limit”中更改。

回答by Silver Light

Array size is limited only by amount of memory your server has. If your array gets too big, you will get "out of memory" error.

数组大小仅受服务器内存量的限制。如果您的数组变得太大,您将收到“内存不足”错误。

回答by prokop

It seems to me to be the 16-bit signed integer limit. (2^15)

在我看来是 16 位有符号整数限制。(2^15)

$ar = [];
while (array_push($ar, null)) {
    print 'a';
}

Length of output: 32768

输出长度: 32768