dnl PHP_ARG_WITH(myext, for myext support,
dnl Make sure that the comment is aligned:
dnl [ --with-myext Include myext support])
去掉dnl
或者将
(不依赖外部库)
dnl PHP_ARG_ENABLE(myext, whether to enable myext support,
dnl Make sure that the comment is aligned:
dnl [ --enable-myext Enable myext support])
去掉dnl
修改头文件php_myext.h
将
PHP_FUNCTION(mytest); /* For testing, remove later. */
更改为
PHP_FUNCTION(myext);
修该扩展C文件myext.c
zend_function_entry php5cpp_functions[] = {
PHP_FE(confirm_myext_compiled, NULL) /* For testing, remove later. */
{NULL, NULL, NULL} /* Must be the last line in php5cpp_functions[] */
};
更改为:
zend_function_entry php5cpp_functions[] = {
PHP_FE(myext, NULL) /* For testing, remove later. */
{NULL, NULL, NULL} /* Must be the last line in php5cpp_functions[] */
};
在该文件的最下面编写你的myext函数
PHP_FUNCTION(myext)
{
zend_printf("hello world\n");
}
保存,按上述方法编译,并修改php.ini
vi test.php
<?php
myext();
运行测试:
/usr/local/php/bin/php test.php
输出:hello,world
完毕
不熟C语言,C高手可以自己编写属于自己的扩展,毕竟运行速度比PHP脚本块M多
我编译出来的,给个图:下载编译出来的so文件