Returning values from your functions to PHP was
described briefly in an earlier section; this section gives
the details. Return values are passed via the return_value variable, which is passed to your
functions as argument. The
return_value argument consists of a
zval container (see the earlier discussion of the call
interface) that you can freely modify. The container itself
is already allocated, so you don't have to run MAKE_STD_ZVAL on it. Instead, you can access
its members directly.
To make returning values from functions easier and to
prevent hassles with accessing the internal structures of the
zval container, a set of predefined
macros is available (as usual). These macros automatically
set the correspondent type and value, as described in 表格 35-1 and 表格 35-2.
注: The macros in 表格 35-1 automatically return from your function, those in 表格 35-2 only set the return value; they don't return from your function.
表格 35-1. Predefined Macros for Returning Values from
a Function
表格 35-2. Predefined Macros for Setting the Return
Value of a Function
Complex types such as arrays and objects can be returned
by using array_init() and object_init(), as well as the corresponding
hash functions on return_value. Since
these types cannot be constructed of trivial information,
there are no predefined macros for them.