当前位置: 首页 > news >正文

第一个php扩展开发的demo

cd /root/soft/php/php-5.2.6/ext
./ext_skel --extname=heiyeluren
cd /root/soft/php/php-5.2.6/ext/heiyeluren
vi config.m4
打开文件后去掉 dnl ,获得下面的信息:
PHP_ARG_ENABLE(rot13, whether to enable heiyeluren support,
[  --enable-heiyeluren           Enable heiyeluren support])
保存退出.

vim php_rot13.h 

找到:PHP_FUNCTION(confirm_ rot13_compiled); ,新增一行:

PHP_FUNCTION(rot13_test); 

vim rot13.c

数组里增加我们的函数,找到 zend_function_entry rot13_functions[],增加:

PHP_FE(rot13_test, NULL)

再到 rot13.c 文件最后面增加如下代码:
PHP_FUNCTION(heiyeluren_test)
{
    char *arg = NULL;
    int arg_len, len;
    char *strg;

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
        return;
    }

    len = spprintf(&strg, 0, "Your input string: %s/n", arg);
    RETURN_STRINGL(strg, len, 0);
}
保存退出。

编译安装

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make test
sudo make install

sudo cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/rot13.so rot13.so

检查安装结果

php -m

http://blog.csdn.net/heiyeshuwu/article/details/3453854

http://www.lryc.cn/news/248585.html

相关文章:

  • A stop job is running for Session c1 of user root (25s 1min 30s)问题
  • C语言进阶之笔试题详解(2)
  • 【开源】基于Vue和SpringBoot的独居老人物资配送系统
  • Linux常用命令----cp 命令
  • 前端:HTML鼠标样式及其对应的CSS属性值
  • Linux 命令chgrp chown chmod
  • 网络篇---第七篇
  • Webshell混淆免杀的一些思路
  • MacBook macOs安装RabbitMQ【超详细图解】
  • 基于格攻击的密钥恢复方法
  • Redis中的缓存穿透、雪崩、击穿(详细)
  • iframe
  • rust 基本数据类型
  • centos7中通过kubeadmin安装k8s集群
  • 普中STM32 单片机资料
  • docker报错
  • pytest分布式执行(pytest-xdist)
  • spring和springBoot
  • laraval6.0 GatewayWorker 交互通信
  • 循环神经网络RNN
  • 为什么预处理对象会提升处理的性能
  • 智能超声波雾化器pcba方案
  • Git分支合并导致文件异常
  • Linux(11):Linux 账号管理与 ACL 权限设定
  • AMEYA360:村田首款1608M尺寸/100V静电容量1µF的MLCC实现商品化
  • 简易键值对文本解析
  • 成为AI产品经理——模型评估(混淆矩阵)
  • Git_git相关指令 高阶
  • PC企业微信http协议逆向接口开发,发送大视频文件
  • hyper-V操作虚拟机ubuntu 22.03