进入到下载的php源码文件中的ext文件夹下 1.cd XXXXX/ext 2.执行ext_skel命令 ./ext_skel --extname=my_module 3.在ext的文件夹下会多出一个名为my_module的文件夹 进入到my_module的文件夹中 cd my_module 4.打config.m4文件 找到如下三行 dnl PHP_ARG_ENAB
进入到下载的php源码文件中的ext文件夹下
1.cd XXXXX/ext
2.执行ext_skel命令
./ext_skel --extname=my_module
3.在ext的文件夹下会多出一个名为my_module的文件夹
进入到my_module的文件夹中
cd my_module
4.打config.m4文件
找到如下三行
dnl PHP_ARG_ENABLE(my_module, whether to enable my_module support,
dnl Make sure that the comment is aligned:
dnl [ --enable-my_module Enable my_module support])
把这三行前面的dnl去掉,保存
5.修改php_my_module.h文件
在 PHP_FUNCTION(confirm_my_module_compiled);后面加入一行
PHP_FUNCTION(my_func);
6.my_module.c文件的
const zend_function_entry my_module_functions[] = {
PHP_FE(confirm_my_module_compiled, NULL) /* For testing, remove later. */
PHP_FE_END /* Must be the last line in my_module_functions[] */
};中加入PHP_FE(my_func,NULL)
加入后的代码如下:
const zend_function_entry my_module_functions[] = {
PHP_FE(confirm_my_module_compiled, NULL) /* For testing, remove later. */
PHP_FE(my_func,NULL)
PHP_FE_END /* Must be the last line in my_module_functions[] */
};
7.在my_module.c文件的结尾处加入my_func函数的实现代码
PHP_FUNCTION(my_func){
php_printf("这是我的第一个扩展库");
}
8.编译安装自己的扩展库
进入到my_module目录下
cd ext/my_module
执行 /usr/loca/php/bin/phpize
./configure --with-php-config=/usr/loca/php/bin/php-config
make & make install
9.在/usr/loca/php/lib/php/extensions/no-debug-non-zts-XXXX目录下生成了一个my_module.so的文件
打开/usr/local/php/lib/php.ini加入一行配置
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-XXXX/my_module.so
10.生启apache服务
编写一个测试文件test.php
<?php my_func(); ?>
打开浏览器输入
localhost/myweb/test.php
回车在浏览器的页面上显示"这是我的第一个扩展库"
至此一个新的php扩展库开发完成

Alat AI Hot

Undresser.AI Undress
Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover
Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool
Gambar buka pakaian secara percuma

Clothoff.io
Penyingkiran pakaian AI

AI Hentai Generator
Menjana ai hentai secara percuma.

Artikel Panas

Alat panas

PhpStorm versi Mac
Alat pembangunan bersepadu PHP profesional terkini (2018.2.1).

Dreamweaver Mac版
Alat pembangunan web visual

Hantar Studio 13.0.1
Persekitaran pembangunan bersepadu PHP yang berkuasa

MantisBT
Mantis ialah alat pengesan kecacatan berasaskan web yang mudah digunakan yang direka untuk membantu dalam pengesanan kecacatan produk. Ia memerlukan PHP, MySQL dan pelayan web. Lihat perkhidmatan demo dan pengehosan kami.

SublimeText3 versi Cina
Versi Cina, sangat mudah digunakan