ITPub博客

首页 > IT职业 > IT图书 > PHP扩展开发[基础]

PHP扩展开发[基础]

IT图书 作者:chunshui 时间:2021-09-09 09:34:00 0 删除 编辑

tar zxvf php-5.4.6.tar.gz
cd php-5.4.6/ext/
./ext_skel –extname=say_hello
cd say_hello
vim config.m4
将“Otherwise use enable”下面三行的“dnl”去掉,改为:

dnl Otherwise use enable:
PHP_ARG_ENABLE(say_hello, whether to enable say_hello support,
Make sure that the comment is aligned:
[ --enable-say_hello Enable say_hello support])

vim say_hello.c

PHP_MINFO_FUNCTION(say_hello)
{
php_info_print_table_start();
php_info_print_table_header(2, “say_hello support”, “enabled”);
php_info_print_table_row(2, “author”, “linux”);
php_info_print_table_end();

}

PHP_FUNCTION(say_hello_func)
{
char *name;
int name_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, “s”, &name, &name_len) == FAILURE)
{
return;
}
php_printf(“Hello %s!”, name);

RETURN_TRUE;
}

ZEND_BEGIN_ARG_INFO(arginfo_say_hello_func, 0)
ZEND_END_ARG_INFO()

const zend_function_entry say_hello_functions[] = {
PHP_FE(say_hello_func, arginfo_say_hello_func) //增加
};

/usr/bin/phpize
./configure
make
make install

vim /etc/php.ini
extension_dir = “/usr/lib/20100212″
extension = “say_hello.so”

;


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3527/viewspace-2804759/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-30

  • 博文量
    98
  • 访问量
    1074