一. 学习php拓展为什么?
1. 高效,可以提高php性能,在php开发效率高的基础上优化了php的性能;
2. 隐蔽,可以隐藏php代码,把php抽象层的代码隐蔽于so文件中,可以高效、隐蔽的整合代码;
二. 拓展第一步hello world
./ext/ext_skel --extname=hello
vi ext/hello/config.m4
去掉dnl PHP_ARG_WITH(hello, for hello support)和[ --with-hello Include hello support]前dnl
执行
./buildconf --force
./configure --[with|enable]-hello
make
./configure --help | grep "hello"
./sapi/cli/php -f ext/hello/hello.php
vi ext/example/example.c
添加
PHP_FUNCTION(confirm_hello_compiled)
{
char *str;
str = estrdup("hellow world!!!");
RETURN_STRING(str, 0);
}
make