When PHP7 extensions were written, some of the kernel methods provided were not fully compatible with previous versions of PHP. There are a number of methods to adjust the parameters. The following are some of the problems encountered during the migration process. Write it down and avoid the pit.
Add_assoc_stringl
The method parameter is changed to four.
Add_assoc_stringl (Parray, key, value, Value_len);
When migrating, just delete the last parameter.
Add_assoc_string
The method parameter changed from four to three.
Add_assoc_stringl (Parray, key, value);
When migrating, just delete the last parameter.
Add_next_index_stringl
The method parameter changed from four to three.
Add_next_index_stringl (Parray, value, Value_len);
When migrating, just delete the last parameter.
Add_next_index_string
The method parameter changed from three to two.
Add_next_index_string (Parray, value);
When migrating, just delete the last parameter.
Return_stringl
The method parameter changed from three to two.
Return_stringl (value, length);
When migrating, just delete the last parameter.
Error: ' Int64_max ' has not been declared in this scope
The reason for the in-depth study. Add a line to the #include "php.h"
#include <stdint.h>
#ifndef int64_max
# define Int64_max int64_c (9223372036854775807)
#endif
#ifndef int64_min
# define Int64_min (-int64_c (9223372036854775807)-1)
#endif
Solve.
Creating a Class
You can refer to the Mysqli_objects_new method in the mysqli extension mysqli.c file.
Variable declarations are allocated from the heap, and instead are allocated on the stack.
For example, the original code is
zval* sarray_l;
Alloc_init_zval (sarray_l);
Array_init (sarray_l);
To
Zval sarray_l;
Array_init (&sarray_l);
Zend_hash_get_current_key_ex
The method parameter changed from six to four.
Zend_api int Zend_fastcall zend_hash_get_current_key_ex (const HashTable *HT, zend_string **str_index, Zend_ulong-*num_ Index, hashposition *pos);
When migrating, simply delete the third and fifth parameters.
Error: ' Z_TYPE_PP ' has not been declared in this scope
There are no Z_TYPE_PP macros, only definitions of Z_type and z_type_p macro methods.
H2 error: Cannot convert from ' zend_string* ' to ' const char* '
The processing of strings in PHP7 is stored using zend_string. If you want to convert zend_string to const char. You need to use the Zstr_val () macro method. The code is as follows:
Zend_string *str;
char *sptr;
.....
Sptr = Zstr_val (str);
Error: ' Is_bool ' has not been declared in this scope
There are no is_bool types. But it is divided into is_true and Is_false.
Error: ' Z_bval ' has not been declared in this scope
No Z_bval macros have been made. But it can be judged by whether the type is is_true and Is_false.
If the type is Is_true, the value is TRUE. If the type is Is_false, the value is false.
Error: ' Zend_object_store_get_object ' has not been declared in this scope
Add the following code:
Static inline Hsf_object *hsf_fetch_object (zend_object *obj)/* {{* * * * return
(User_object *) ((char*) (obj)-XTOFFSE TOf (User_object, STD));
}
/*}}/* *
#define Z_USEROBJ_P (ZV) Hsf_fetch_object (Z_obj_p ((ZV))
Then change the zend_object_store_get_object to z_userobj_p.
Note that User_object is the structure you define.
The above is a description of the PHP extended migration for PHP7 extended compatibility issues record, I hope to help you.