PHP extension
Zend
Data structure
Array与HashTable
Hello World!
MM
引用计数
C: malloc、free、strdup、realloc、calloc
VAR
创建PHP变量
ZVAL_STRING(pzv, str, dup);
ZVAL_STRINGL(pzv,str,len,dup);
ZVAL_BOOL(pzv, b);
ZVAL_NULL(pvz);
值
...
8种数据类型
#define Z_TYPE(zval) (zval).type
#define Z_TYPE_P(zval_p) Z_TYPE(*zval_p)
#define Z_TYPE_PP(zval_pp) Z_TYPE(**zval_pp)
IS_RESOURCE
IS_OBJECT
IS_ARRAY
HashTable
IS_STRING
IS_DOUBLE
signed double
IS_LONG
signed long
IS_BOOL
true; false
IS_NULL
null
zval
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;
} zvalue_value;
struct _zval_struct {
zvalue_value value; /* 变量的值 */
zend_uint refcount__gc;
zend_uchar type; /* 变量当前的数据类型 */
zend_uchar is_ref__gc;
};
typedef struct _zval_struct zval;
typedef unsigned int zend_uint;
typedef unsigned char zend_uchar;
Lifecycles
PHP的启动与终止
MSHUTDOWN
PHP_MSHUTDOWN_FUNCTION
Module Shutdown
RSHUTDOWN
PHP_RSHUTDOWN_FUNCTION
Request Shutdown
RINIT
PHP_RINIT_FUNCTION
Request Initialization
MINIT
PHP_MINIT_FUNCTION
MINIT全称Module Initialization,是由每个扩展自己实现的一个函数
PHP Architecture