继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

PHP扩展开发[基础]

慕用4979188
关注TA
已关注
手记 266
粉丝 63
获赞 531

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
*/
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”); /* Replace with your name */
php_info_print_table_end();
/* Remove comments if you have entries in php.ini
DISPLAY_INI_ENTRIES();
*/
}
/* }}} */

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”

;


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP