Talking about PHP source code 12: About Return_value return value

Source: Internet
Author: User
Tags php source code
This article mainly introduces about the PHP source code 12: About the Return_value return value, has a certain reference value, now share to everyone, the need for friends can refer to

Read PHP source for some time, know that in the extension function as long as the use of php_function, and assign the value to Return_value can return the value of this function.
Then self-tracking code, always thought that there is a return_value such a global variable or contains return_value global hashtable exist, and then constantly debugging, has not been found,
Not until today asked the bird brother suddenly wake up, brother Bird in the Mail said: "Return_value is PHP in all the PHP script provides a function php_fuction a parameter, through the macro expansion. By copying to this parameter, Ze will return the value to the front-end call script. ”

Its macro is defined as follows:

#define Php_function zend_function#define zend_function (name) zend_named_function (ZEND_FN (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

Some built-in functions (such as each) use Zend_function directly
Extension functions use Php_function

In some extension functions we often see that some are not using return_value, but instead use some macros that contain return_value.
The common macros are as follows:

  ZEND_API.H 500 lines start #define ZVAL_FALSE (z) zval_bool (z, 0) #define ZVAL_TRUE (z) zval_bool (z, 1) #define Retv Al_resource (L) zval_resource (Return_value, L) #define Retval_bool (b) Zval_bool (Return_value, b) #define RETVAL_NULL () Z Val_null (return_value) #define Retval_long (L) Zval_long (Return_value, L) #define Retval_double (d) zval_double (return_ Value, D) #define Retval_string (S, duplicate) zval_string (Return_value, S, duplicate) #define RETVAL_STRINGL (S, L, dupli Cate) Zval_stringl (Return_value, S, l, duplicate) #define retval_empty_string () zval_empty_string (return_value) #  Define Retval_zval (Zv, copy, Dtor) zval_zval (Return_value, Zv, copy, dtor) #define Retval_false zval_bool (Return_value,  0) #define Retval_true zval_bool (return_value, 1) #define RETURN_RESOURCE (l) {retval_resource (L); return;}  #define Return_bool (b) {retval_bool (b); RETURN;}  #define Return_null () {retval_null (); RETURN;}  #define Return_long (L) {Retval_long (l); RETURN;} #define RETurn_double (d) {retval_double (d); return;}  #define RETURN_STRING (S, duplicate) {retval_string (S, duplicate); RETURN;}  #define RETURN_STRINGL (S, l, duplicate) {Retval_stringl (S, l, duplicate); RETURN;}  #define Return_empty_string () {retval_empty_string (); RETURN;}  #define RETURN_ZVAL (Zv, copy, dtor) {retval_zval (Zv, copy, dtor); RETURN;}  #define RETURN_FALSE {retval_false; RETURN;} #define RETURN_TRUE {retval_true; RETURN;}

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.