I'm just experimenting with a PHP extension and I would like to know what is the suggested/preferred way to call an object constructor within the extension. I've read that, by calling the object_init_ex function the constructor of that object is not automatically called. This seems true also from the tests I've made. Let us say that I have the following code where 'Person' is a valid class name:
zend_class_entry *class_entry = NULL;
zend_string *class_name = zend_string_init("Person", sizeof("Person") - 1, false);
class_entry = zend_lookup_class(class_name);
if (class_entry != NULL) {
object_init_ex(return_value, class_entry);
/* call the Person::_construct method */
} else {
RETURN_NULL();
}
How can I call the constructor after the object_init_ext call? Also, will there be any differences between php 5 and php 7 in this regard?