|
ZEND_BEGIN_ARG_INFO_EX(global_config_arg, 0, 0, 1)
ZEND_ARG_INFO(0, global_config)ZEND_END_ARG_INFO()/**
* 声明构造函数
* @param
* @return
*/ZEND_METHOD(person,__construct){
zval *array_config;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array_config) == FAILURE) {
RETURN_NULL();
}
//php_var_dump( &array_config,1 TSRMLS_CC); zend_update_property(person_ce, getThis(), "config", sizeof("config")-1, array_config TSRMLS_CC);}/**
* 声明析造函数
* @param
* @return
*/ZEND_METHOD(person,__destruct){
zend_printf("destruct\n");}ZEND_METHOD(person,doing){
//array_init(return_value); zval *array_config;
zval rv; //php >=7.0
array_config = zend_read_property(person_ce, getThis(), "config", sizeof("config")-1, 0, &rv TSRMLS_DC);
if( Z_TYPE_P(array_config) == IS_NULL || Z_TYPE_P(array_config) != IS_ARRAY ){
//zend_error(E_ERROR, "framework config error!"); RETURN_FALSE;
}
//php_var_dump(&array_config, 1 TSRMLS_CC);
RETURN_ZVAL(array_config, 1, 0);
//zend_printf("doing\n");}ZEND_METHOD(person,saying){
if (zend_parse_parameters_none() == FAILURE) {
RETURN_FALSE;
}
array_init(return_value);
//zend_printf("saying\n");}//这个函数需要加上声明,去掉了没用的test函数const zend_function_entry person_functions[] = {
ZEND_ME(person, __construct, global_config_arg, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
ZEND_ME(person,doing,NULL,ZEND_ACC_PUBLIC)
ZEND_ME(person,saying,NULL,ZEND_ACC_PUBLIC)
ZEND_ME(person,__destruct,NULL,ZEND_ACC_PUBLIC|ZEND_ACC_DTOR)
PHP_FE_END /* Must be the last line in person_functions[] */};//将类和方法注册到zendPHP_MINIT_FUNCTION(person){
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "person", person_functions);
person_ce = zend_register_internal_class(&ce TSRMLS_CC);
zend_declare_property_null(person_ce,"saying",strlen("saying"),ZEND_ACC_PUBLIC);
zend_declare_property_null(person_ce,"doing",strlen("doing"),ZEND_ACC_PUBLIC);
return SUCCESS;}
|
|
|