PHP extension migrated to compatible PHP7 records

Source: Internet
Author: User

when the PHP7 extension is written, some of the kernel methods provided are not fully compatible with previous versions of PHP. There are many ways to adjust the parameters. The following are some of the issues encountered during the migration process. Record it and avoid the pit. PHP7 extension development of the Hello Word vernacular PHP7 The Creation object Add_assoc_stringl method parameter changed to four. Add_assoc_stringl (Parray, key, value, Value_len); When migrating, simply delete the last parameter. The Add_assoc_string method parameter changed from four to three. Add_assoc_stringl (Parray, key, value); When migrating, simply delete the last parameter. The Add_next_index_stringl method parameter changed from four to three. Add_next_index_stringl (Parray, value, Value_len); When migrating, simply delete the last parameter. The Add_next_index_string method parameter changed from three to two. Add_next_index_string (Parray, value); When migrating, simply delete the last parameter. The Return_stringl method parameter changed from three to two. Return_stringl (value, length); When migrating, simply delete the last parameter. Error: ' Int64_max ' has not been declared in this scope for in-depth study. In #include"Php.h"plus One line # # #<stdint.h>#ifndef int64_max# define Int64_max int64_c (9223372036854775807)#endif#ifndef int64_min# define Int64_min (-int64_c (9223372036854775807)-1)#endifresolved. Create a class to refer to the Mysqli_objects_new method in the mysqli extension mysqli.c file. Variable declarations are allocated from the heap and are allocated on the stack instead. For example, the original code is Zval*sarray_l; Alloc_init_zval (sarray_l); Array_init (sarray_l); Zval Sarray_l;array_init (&sarray_l); zend_hash_get_current_key_ex method parameter changed from six to four. Zend_apiintZend_fastcall ZEND_HASH_GET_CURRENT_KEY_EX (ConstHashTable *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 declared in this scope that there are no Z_TYPE_PP macros, only the Z_type and Z_type_p macro methods are defined. &LT;&GT;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_stringConst 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 that there is no is_bool type. It is divided into is_true and is_false. Error: ' Z_bval ' has not been declared in this scope that there are no z_bval macros. However, it can be judged by whether the type is is_true and Is_false. If the type is Is_true, the value is TRUE. The value is False if the type is is_false. Error: ' Zend_object_store_get_object ' has not been declared in this scope to add the following code:StaticInline Hsf_object *hsf_fetch_object (zend_object *obj)/* {{{ */ {    return(User_object *) ((Char*) (obj)-xtoffsetof (user_object, STD)); } /* }}} */ #defineZ_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. Original link: PHP extension migration to compatible PHP7 records, reproduced please indicate the source! 

PHP extension migrated to compatible PHP7 records

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.