PHP扩展开发[基础]

tar zxvf php-5.4.6.tar.gz
cd php-5.4.6/ext/
./ext_skel �Cextname=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”

;


你可能感兴趣的:(PHP,extension)