Php_arg_with or php_arg_enable specifies the working mode of the PHP module. Select either of them.
Php_require_cxx is used to specify that the extension uses C ++
Php_subst (extern_name_shared_libadd) is used to demonstrate how this extension is compiled into a dynamic link library.
Php_add_library (stdc ++, "", sysfile_shared_libadd) is used to link the Standard C ++ Library to the extension
Php_new_extension is used to specify which source files should be compiled and separated by spaces.
The default module framework generated by ext_skel is for C. To use C ++, the three or five macros above are required. in addition, testext. C is renamed to testext. CPP, so php_new_extension originally included testext. C also needs to be modified.
After using C ++, pay attention to a small problem, that is, the php_testext.h file may be referenced by other parts of PHP, And the quotor may be. c file, so it cannot contain anything unique to C ++ in php_testext.h. for example, the standard template library, class, or bool type.
Testext. C (now renamed testext. CPP). It already contains a test-type export function. You can use that example to understand how to add your own function. zend_function_entry is the list of exported functions. zend_module_entry describes the module information. but because it is C ++, there are several points to modify:
# Include "php. H" # include "php_ini.h" # include "ext/standard/info. H"
Use extern "c" to modify.
Zend_get_module must also be modified with extern "C"
Zend_module_entry is the type used to describe the module information. It is actually a structure, and the second item does not know what it means. in Windows, it seems to be a description, which can be a long string, but in Linux it seems that it can only be the same as the module name.
The subsequent work is to write your own code. According to the design, provide external interface functions, and then write C/C ++ code for implementation.