Skip to content

zval---Setting the value example code #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
huqinlou0123 opened this issue Sep 7, 2017 · 1 comment
Open

zval---Setting the value example code #38

huqinlou0123 opened this issue Sep 7, 2017 · 1 comment

Comments

@huqinlou0123
Copy link
Contributor

link

PHP_FUNCTION(hello_world) {
    Z_TYPE_P(return_value) = IS_STRING;
    Z_STR_P(return_value) = zend_string_init("hello world!", strlen(""hello world!"), 0);
};

/* ... */
    PHP_FE(hello_world, NULL)
/* ... */

Above Z_TYPE_P(return_value) = IS_STRING;

#define Z_TYPE_P(zval_p) Z_TYPE((zval_p))
#define Z_TYPE(zval) zval_get_type(&(zval)) //获取zval类型
static zend_always_inline zend_uchar zval_get_type(const zval
pz) {
return pz->u1.v.type;
}

this way is it wrong?

@nikic
Copy link
Collaborator

nikic commented Sep 7, 2017

Yeah, this doesn't work. This was taken over from the PHP 5 version, where this used to work. In PHP 7 one should use ZVAL_STR or ZVAL_STRING.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants