background image

//zend_function_entry myext_functions[] = {
// PHP_FE(confirm_myext_compiled, NULL) /* For testing, remove later. */
// {NULL, NULL, NULL} /* Must be the last line in myext_functions[] */
//};
//修改为
zend_function_entry myext_functions[] = {
PHP_FE(myext, NULL) /* For testing, remove later. */
{NULL, NULL, NULL} /* Must be the last line in myext_functions[] */
};
//在文件底部添加自己的函数
PHP_FUNCTION(myext)
{
zend_printf("Hello World!\n");
}
安装自己的 php 扩展 myext:
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
修改 php.ini,添加:
extension = "myext.so"
重启 web 服务器,查看 phpinfo,即可看到自己的扩展:

新建测试 php 文件:
<?php
myext();

执行此文件,即可看到再熟悉不过的 Hello World ”

! 。