PHP Zend Engine Extension and static methods

≯℡__Kan透↙ 提交于 2019-12-10 17:43:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!