這裏特別感謝laruence(鳥哥)開源的yaf擴展,解決困擾我多時的多類問題,還在看他的代碼學習中,這裏是對多類寫法學習的一個階段總結。php
#define SIMPLE_STARTUP (module) ZEND_MODULE_STARTUP_N(simple_##module)(INIT_FUNC_ARGS_PASSTHRU ) #define SIMPLE_MINIT_FUNCTION (module) ZEND_MINIT_FUNCTION(simple_##module)
#ifndef _SIMPLE_UTIL_H_ #define _SIMPLE_UTIL_H_ extern zend_class_entry *simple_util_ce; SIMPLE_MINIT_FUNCTION(util); #endif
#ifdef HAVE_CONFIG_H #include "config.php" #endif #include "php.h" #include "php_ini.h" #include "Zend/zend_interfaces.h" #include "php_simple.h" #include "simple_util.h" //這裏是定義靜態類 static zend_class_entry *simple_util_ce; /** {{{ ARG_INFO */ ZEND_BEGIN_ARG_INFO_EX(simple_util_void_arginfo, 0, 0, 0) ZEND_END_ARG_INFO() /* }}} */ PHP_METHOD(simple_util, read) { RETURN_STRING("這裏返回函數結果" , 1); } zend_function_entry simple_util_methods[] = { PHP_ME(simple_util, read, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC ) { NULL, NULL, NULL } }; //至關於把多個擴展合在一塊兒,每一個類各自ZEND_MINIT_FUNCTION SIMPLE_MINIT_FUNCTION(util) { zend_class_entry ce; INIT_CLASS_ENTRY(ce, "Util" , simple_util_methods); simple_util_ce = zend_register_internal_class_ex(&ce, NULL, NULL TSRMLS_CC); return SUCCESS; }
PHP_MINIT_FUNCTION(boxun) { REGISTER_INI_ENTRIES(); SIMPLE_STARTUP(util); return SUCCESS; }