php源码分析(二)
php核心目录zend分析之变量分析
1,了解php变量类型
null bool int double str array resource object (共8种)
2,php是弱语言类型,php解释成c执行而c是强类型,php源码中zend引擎是如何转换分析的?
3,php-str/zend/zend.h 300行左右直接看源码

4,当$a=3 执行会 生成一个struce,
struct 如上有4部分组成
{ /* Variable information */ zvalue_value value; /* value */ zend_uint refcount__gc; zend_uchar type; /* active type */ zend_uchar is_ref__gc; }
对应的 $a=3 的机构体
{
union_value
{
int:3
len:1
}
type:IS_INT
rfcount_gc:1
is_ref_gc:0
}
4,结构体只保存变量的值,变量的名在哪?
php使用符号表来存储变量名 php-str/zend/zend_globals.h 182行左右
symbol_table 这张hash表 来保存全局 变量
HashTable *active_symbol_table; HashTable symbol_table; /* main symbol table */ HashTable included_files; /* files already included */
变量定义到映射关系


浙公网安备 33010602011771号