PHP扩展开发

Posted 心随所遇

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP扩展开发相关的知识,希望对你有一定的参考价值。

安装好php,进入安装目录.

[email protected]:/usr/local/php-5.6.28/ext$ ./ext_skel --extname=mytest
[email protected]:/usr/local/php-5.6.28/ext$ cd mytest
[email protected]:/usr/local/php-5.6.28/ext/mytest$ gedit config.m4
 
###编辑文件(16 - 18行)
PHP_ARG_ENABLE(mytest, whether to enable mytest support,
dnl Make sure that the comment is aligned:
[  --enable-mytest           Enable mytest support])
 
[email protected]:/usr/local/php-5.6.28/ext/mytest$ ../../scripts/phpize
[email protected]:/usr/local/php-5.6.28/ext/mytest$ sudo apt-get install autoconf
[email protected]:/usr/local/php-5.6.28/ext/mytest$ make
[email protected]:/usr/local/php-5.6.28/ext/mytest$ sudo make install
[email protected]:/usr/local/php-5.6.28/ext/mytest$ php -i | grep php.ini
 
###在ini文件中添加扩展: extension=mytest.so
 
[email protected]:/usr/local/php-5.6.28/ext/mytest$ php -r ‘echo confirm_mytest_compiled("\nHello World!")."\n";‘
Congratulations! You have successfully modified ext/mytest/config.m4. Module 
Hello World! is now compiled into PHP.

以上是关于PHP扩展开发的主要内容,如果未能解决你的问题,请参考以下文章

PHP 扩展开发(将自己的一些代码封装成PHP扩展函数)

php扩展开发2--添加类

一本关于 PHP 扩展开发的书——《PHP internals Book》

PHP扩展开发 - PHP常量的定义和读取

PHP扩展开发及内核应用

php扩展开发-快速上手