在擴展開發中,並不是所有的功能都需要自已去實現 。可以調用一些其他擴展已經實現的函數。
調用內核標準函數
如下面是調用php_string_tolower的過程。
引入頭文件
#include "ext/standard/php_string.h"
然後可以直接使用引入文件中的PHPAPI 開頭的標準函數。
如下:
PHP_FUNCTION(rsautil_test1)
{
zend_string *str;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_STR(str)
ZEND_PARSE_PARAMETERS_END();
RETURN_STR(php_string_tolower(str));
php 調用結果:
var_dump(rsautil_test1("ABCDefghijklmNOPQRST"));
output
string(20) "abcdefghijklmnopqrst"
調用內核函數和php定義的函數
call_user_function(function_table, object, function_name, retval_ptr, param_count, params)
通過調用call_user_function可以調用內核和php定義的函數。