PHP中Zval是什么

1、概念

Zval是zend中另一个非常重要的数据结构,用来标识并实现PHP变量。包含了PHP中的变量值和类型的相关信息。

2、组成

type:指定了变量所述的类型(整数、字符串、数组等)

refcount&is_ref:用来实现引用计数(后面具体介绍)

value:核心部分,存储了变量的实际数据

3、实例

struct_zval_struct{
union{
zend_longlval;/*longvalue*/
doubledval;/*doublevalue*/
zend_refcounted*counted;
zend_string*str;
zend_array*arr;
zend_object*obj;
zend_resource*res;
zend_reference*ref;
zend_ast_ref*ast;
zval*zv;
void*ptr;
zend_class_entry*ce;
zend_function*func;
struct{
uint32_tw1;
uint32_tw2;
}ww;
}value;
union{
struct{
ZEND_ENDIAN_LOHI_4(
zend_uchartype,/*activetype*/
zend_uchartype_flags,
zend_ucharconst_flags,
zend_ucharreserved)/*callinfoforEX(This)*/
}v;
uint32_ttype_info;
}u1;
union{
uint32_tvar_flags;
uint32_tnext;/*hashcollisionchain*/
uint32_tcache_slot;/*literalcacheslot*/
uint32_tlineno;/*linenumber(forastnodes)*/
uint32_tnum_args;/*argumentsnumberforEX(This)*/
uint32_tfe_pos;/*foreachposition*/
uint32_tfe_iter_idx;/*foreachiteratorindex*/
}u2;
};
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。