I am writing a PHP extension recently. it is found that the internal iterator interface functions of the two versions have some changes, the differences are as follows: {code ...} this change is associated with the PHP version: {code ...} still associated with extended version: {code ...} how can I adapt to different versions of Apis? I am writing a PHP extension recently.
It is found that the internal iterator interface functions of the two versions have some changes, the differences are as follows:
{php-src}/Zend/zend_interface.c (in 5.3.X): ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)----------------------------------------------------------------------------------{php-src}/Zend/zend_interface.c (in 5.4.X): ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key TSRMLS_DC)
This change is associated with the PHP version:
5.3---5.4
Associated with the extended version:
PHP Api Version: 20100412Zend Module Api No: 20100525Zend Extension Api No: 220100525----------------------------------PHP Api Version: 20090626Zend Module Api No: 20090626Zend Extension Api No: 220090626
How can I adapt to different versions of Apis?
Reply content:
I am writing a PHP extension recently.
It is found that the internal iterator interface functions of the two versions have some changes, the differences are as follows:
{php-src}/Zend/zend_interface.c (in 5.3.X): ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)----------------------------------------------------------------------------------{php-src}/Zend/zend_interface.c (in 5.4.X): ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key TSRMLS_DC)
This change is associated with the PHP version:
5.3---5.4
Associated with the extended version:
PHP Api Version: 20100412Zend Module Api No: 20100525Zend Extension Api No: 220100525----------------------------------PHP Api Version: 20090626Zend Module Api No: 20090626Zend Extension Api No: 220090626
How can I adapt to different versions of Apis?
At least from the source code, it does not matter with ZEND_MODULE_API_NO and ZEND_EXTENSION_API_NO.
It can only be PHP_API_VERSION.
zend_interfaces.c
In this example, some userspace iterator interfaces are defined.
Are you using the source code of the 5.4 Development Branch? This function interface is modified to: Added support for non-scalar Iterator keys in foreach.
However, this feature is supported only when it is 5.5.zend_user_it_get_current_key
The signature of this function remains unchanged.
In my opinion, one way is:
#if PHP_API_VERSION < 20120000#else#endif
But I never step on it.