PHP扩展 - 从另一个PHP函数调用自己的PHP函数 [英] PHP extensions - call your own PHP function from another PHP function
本文介绍了PHP扩展 - 从另一个PHP函数调用自己的PHP函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说我们有一个自定义的PHP扩展,如:
Let's say we have a custom PHP extension like:
PHP_RSHUTDOWN_FUNCTION(myextension)
{
// How do I call myfunction() from here?
return SUCCESS;
}
PHP_FUNCTION(myfunction)
{
// Do something here
...
RETURN_NULL;
}
我怎么能说从RSHUTDOWN处理MyFunction的()?
How can I call myfunction() from the RSHUTDOWN handler?
推荐答案
使用提供的宏调用将是:
Using the provided macros the call will be:
PHP_RSHUTDOWN_FUNCTION(myextension)
{
ZEND_FN(myFunction)(0, NULL, NULL, NULL, 0 TSRMLS_CC);
return SUCCESS;
}
当你定义你的 PHP_FUNCTION功能(myFunction的)
的preprocessor将扩大你定义:
When you're defining you function as PHP_FUNCTION(myFunction)
the preprocessor will expand you're definition to:
ZEND_FN(myFunction)(INTERNAL_FUNCTION_PARAMETERS)
这又是:
zif_myFunction(int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC)
这zend.h和php.h的宏:
The macros from zend.h and php.h:
#define PHP_FUNCTION ZEND_FUNCTION
#define ZEND_FUNCTION(name) ZEND_NAMED_FUNCTION(ZEND_FN(name))
#define ZEND_FN(name) zif_##name
#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
#define INTERNAL_FUNCTION_PARAMETERS int ht, zval *return_value, zval **return_value_ptr, zval *this_ptr, int return_value_used TSRMLS_DC
#define INTERNAL_FUNCTION_PARAM_PASSTHRU ht, return_value, return_value_ptr, this_ptr, return_value_used TSRMLS_CC
这篇关于PHP扩展 - 从另一个PHP函数调用自己的PHP函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文