问题
On writing an extension for php (5.3) i want to access the zend_class_entry pointer on a static method.
On non static methods i can use the getThis() macro and within Z_OBJCE_P macro like this:
zend_class_entry ce* = Z_OBJCE_P(getThis());
Now the problem:
on static methods the getThis() macro returns a null pointer, so i can not use the Z_OBJCE_P macro.
Has anyone a solution for me to access the zend_class_entry from a static method??
回答1:
it is really interesting: on static methods you can access the scope like this
zend_class_entry* ce = 0L;
if (EG(called_scope)) {
ce = EG(called_scope);
} else if (!EG(scope)) {
ce = EG(scope);
}
the EG Macro access a lot of global and context specific variables, also the calling scope, the calling class of the static method.
来源:https://stackoverflow.com/questions/4514202/php-zend-engine-extension-and-static-methods