【发布时间】:2017-05-18 04:21:44
【问题描述】:
我想在php扩展中实现如下代码
class A{
public function __construct(){
}
}
class B extends A{
public function __construct(){
parent::__construct();
}
}
我写了这些:
zend_class_entry *a_class_ce, *b_class_ce;
ZEND_METHOD(a_class, __construct){
}
ZEND_METHOD(b_class, __construct){
}
static zend_function_entry a_class_method[]={
ZEND_ME(a_class, __construct, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
static zend_function_entry b_class_method[]={
ZEND_ME(b_class, __construct, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
ZEND_MINIT_FUNCTION(test){
zend_class_entry a_ce, b_ce;
INIT_CLASS_ENTRY(a_ce, "A", a_class_method);
a_class_ce = zend_register_internal_class(&a_ce TSRMLS_CC);
INIT_CLASS_ENTRY(b_ce, "B", b_class_method);
b_class_ce = zend_register_internal_class_ex(&b_ce, b_class_ce TSRMLS_CC);
return SUCCESS;
}
但是不知道怎么实现 parent::__construct();
如何实现parent :: __construct()?
【问题讨论】:
-
@Luke 我不是 PHP 大师,但嗯...不,IMO 这与 与 Zend 框架没有任何关系。
-
@AnttiHaapala 谢谢,我离题了。
标签: php php-extension