php底层变量

 

在zend目录中的zend.h中会发现变量是这样定义的

typedef union _zvalue_value {
long lval; /* long value */
double dval; /* double value */
struct {
char *val;
int len;
} str;
HashTable *ht; /* hash table value */
zend_object_value obj;
zend_ast *ast;
} zvalue_value;

 

struct _zval_struct {
/* Variable information */
zvalue_value value; /* value */
zend_uint refcount__gc;
zend_uchar type; /* active type */
zend_uchar is_ref__gc;
};

zval结构体就是PHP的变量

一共有4个成员变量

value代表变量的值 refcount__gc变量的引用数 type变量的类型 is_ref__gc是否被引用 value的结构类型对应上面的_zvalue_value 的联合体

ZEND引擎定义了以下几种变量类型 php 版本(5.6.8)

 

posted @ 2015-05-01 14:28  纠结的小情绪  阅读(170)  评论(0)    收藏  举报