私はPHPの非常に基本的なことを学んでいて、突然「変数はどのメモリ形式でメモリに格納されているのですか?」という考えに出くわしました。
それはスタックですか、それともヒープですか?
このメモリ内の変数割り当てを研究するための参考資料を提供してください..
私はPHPの非常に基本的なことを学んでいて、突然「変数はどのメモリ形式でメモリに格納されているのですか?」という考えに出くわしました。
それはスタックですか、それともヒープですか?
このメモリ内の変数割り当てを研究するための参考資料を提供してください..
PHP はzval/pval
、基本的なデータ コンテナーとして使用します。
struct _zval_struct {
zvalue_value value; // The value
zend_uint refcount__gc; // The number of references to this value (for GC)
zend_uchar type; // The type
zend_uchar is_ref__gc; // Whether this value is a reference (&)
};
typedef union _zvalue_value {
long lval; // For integers and booleans
double dval; // For floats (doubles)
struct { // For strings
char *val; // consisting of the string itself
int len; // and its length
} str;
HashTable *ht; // For arrays (hash tables)
zend_object_value obj; // For objects
} zvalue_value;
これらは zend.h で定義されています: http://lxr.php.net/xref/PHP_5_4/Zend/zend.h#318