PHP. Руководство по PHP. 2005
Returning ValuesПред. След. |
Глава 55. Returning Values
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 Табл. 55-1 and Табл. 55-2.
Замечание: The macros in Табл. 55-1 automatically return from your function, those in Табл. 55-2 only set the return value; they don't return from your function.