Recently in writing a PHP extension.
There is a slight change in the internal iterator interface functions between the two versions, with the following differences:
{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
or associated with an 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 to adapt to different versions of the API?
Reply content:
Recently in writing a PHP extension.
There is a slight change in the internal iterator interface functions between the two versions, with the following differences:
{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
or associated with an 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 to adapt to different versions of the API?
At least from the source, and Zend_module_api_no, Zend_extension_api_no no relationship.
It's only php_api_version.
zend_interfaces.c
This inside of these several methods is defined by some userspace iterator interfaces.
Are you using the source code of the 5.4 Development branch? Because this function interface is changed to: Added support for Non-scalar Iterator keys in foreach.
However, this feature is only supported at 5.5, and the zend_user_it_get_current_key
signature of this function in 5.4 has not changed before.
I think one way of doing this is to:
#if PHP_API_VERSION < 20120000#else#endif
But I've never stepped on it, don't blame me for a hole.