How to write the magic function(__get
and __set
) of PHP7's class in C language. I tried to solve it myself, but I found that it is too difficult for me.
My questions:
zend_read_property
?NULL
if not exist)?My code:
ZEND_METHOD(Cheetah_Kernel_Object,__get) {
char *name;
int name_len;
if (zend_parse_parameters(ZEND_NUM_ARGS()TSRMLS_CC, "s", &name, &name_len)
== FAILURE) {
RETURN_NULL()
}
zend_class_entry *ce = Z_OBJCE_P(getThis());
zend_read_property(ce, getThis(), name, name_len, 0 TSRMLS_CC, {??});
RETURN_NULL()
}