Now that you have declared the functions to be exported,
you also have to introduce them to Zend. Introducing the list
of functions is done by using an array of
zend_function_entry. This array consecutively contains
all functions that are to be made available externally, with
the function's name as it should appear in PHP and its name
as defined in the C source. Internally,
zend_function_entry is defined as shown in
範例 31-1.
zend_function_entry firstmod_functions[] = { ZEND_FE(first_module, NULL) {NULL, NULL, NULL} }; |
注: You cannot use the predefined macros for the end marker, as these would try to refer to a function named "NULL"!
The macro ZEND_FE (short for
'Zend Function Entry') simply expands to a structure entry in
zend_function_entry. Note that these
macros introduce a special naming scheme to your functions -
your C functions will be prefixed with
zif_, meaning that
ZEND_FE(first_module) will refer to a C function zif_first_module(). If you want to mix
macro usage with hand-coded entries (not a good practice),
keep this in mind.
Tip: Compilation errors that refer to functions named zif_*() relate to functions defined with
ZEND_FE.
表格
31-2 shows a list of all the macros that you can use to
define functions.
表格 31-2. Macros for Defining Functions
Note: You can't use
ZEND_FE in conjunction with
PHP_FUNCTION, or PHP_FE in
conjunction with ZEND_FUNCTION.
However, it's perfectly legal to mix
ZEND_FE and ZEND_FUNCTION with
PHP_FE and
PHP_FUNCTION when staying with the same macro set for
each function to be declared. But mixing is not recommended;
instead, you're advised to use the
ZEND_* macros only.