本文介绍了PHP:做阵列有一个最大尺寸是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有在PHP的数组?

Is there a limit for an array in PHP?

推荐答案

是的,有在元素的最大数量限制。哈希表结构(数组基本上包装了一个哈希表)的定义是这样的(PHP 5.3):

Yes, there's a limit on the maximum number of elements. The hash table structure (arrays are basically wrappers around a hash table) is defined like this (PHP 5.3):

typedef struct _hashtable {
    uint nTableSize;
    uint nTableMask;
    uint nNumOfElements;
    ulong nNextFreeElement;
    Bucket *pInternalPointer;   /* Used for element traversal */
    Bucket *pListHead;
    Bucket *pListTail;
    Bucket **arBuckets;
    dtor_func_t pDestructor;
    zend_bool persistent;
    unsigned char nApplyCount;
    zend_bool bApplyProtection;
#if ZEND_DEBUG
    int inconsistent;
#endif
} HashTable;

因为

typedef unsigned int uint;

该限制是一个unsigned int(通常为2 ^ 32-1在32位操作系统和大多数64位操作系统)的最大尺寸。

the limit is the maximum size of an unsigned int (typically 2^32-1 on a 32-bit OS and on most 64-bit OS).

在实践中,然而,除了在有很多内存和32位整数的机器,你会一直打到内存限制之前,这将成为一个问题。

In practice, however, except on machines with lots of RAM and 32-bit ints, you will always hit the memory limit before this becomes an issue.

这篇关于PHP:做阵列有一个最大尺寸是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 14:34
查看更多