php扩展开发-MINFO

我们在用PHPinfo函数或命令行的php -i命令查看php环境相关的信息,当我们开发完成一个自己的扩展,除非这个扩展就是你自己所使用,否则你就需要对扩展进行相关的介绍,或者显示扩展用到的ini配置,这个时候你就可以使用MINFO的函数,把你想展示的信息通过它来等记,最后在phpinfo或php-i中别人可以看到这些信息。

PHP_MINFO_FUNCTION(myext);//php_myext.h

//你想展示的扩展信息
PHP_MINFO_FUNCTION(myext){
  //这里面的内容其实就printf输出,只是php内核提供了一些封装好的函数,方便我们输出 php_info_print_table_start(); php_info_print_table_row(
2, "version", PHP_MYEXT_VERSION); php_info_print_table_row(2, "writer", "zhangxiaomin"); php_info_print_table_end(); } zend_module_entry myext_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 STANDARD_MODULE_HEADER, #endif "myext",//扩展名称 myext_functions,//zend_function_entry myext_functions 定义好的函数扩展变量 PHP_MINIT(myext),//MINIT_FUNCTION NULL,//MSHUTDOWN_FUNCTION NULL,//RINIT_FUNCTION NULL,//RSHUTDOWN_FUNCTION PHP_MINFO(myext),//MINFO_FUNCTION,在这里注册PHP_MINFO_FUNCTION #if ZEND_MODULE_API_NO >= 20010901 PHP_MYEXT_VERSION, #endif STANDARD_MODULE_PROPERTIES };
//ext/standard/info.h
//这些函数已经对cli或HTML的环境做了处理,会分别显示对应的文本内容

PHPAPI char *php_info_html_esc(char *string TSRMLS_DC);
PHPAPI void php_info_html_esc_write(char *string, int str_len TSRMLS_DC);
PHPAPI void php_print_info_htmlhead(TSRMLS_D);
PHPAPI void php_print_info(int flag TSRMLS_DC);
PHPAPI void php_print_style(void);
PHPAPI void php_info_print_style(TSRMLS_D);
PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header);
PHPAPI void php_info_print_table_header(int num_cols, ...);
PHPAPI void php_info_print_table_row(int num_cols, ...);
PHPAPI void php_info_print_table_row_ex(int num_cols, const char *, ...);
PHPAPI void php_info_print_table_start(void);
PHPAPI void php_info_print_table_end(void);
PHPAPI void php_info_print_box_start(int bg);
PHPAPI void php_info_print_box_end(void);
PHPAPI void php_info_print_hr(void);
PHPAPI void php_info_print_module(zend_module_entry *module TSRMLS_DC);

 

posted on 2016-12-31 17:12  平淡生活781  阅读(195)  评论(0编辑  收藏  举报

导航