标签:style io ar 使用 for sp 文件 on cti
先从简单入手,找点感觉
1、计划编写个函数类似(基本不可能会用上,练练没办法)
function htest($str)
{
    return $str . ‘==‘;
} 
2、准备好php安装包,本文使用的php5.5.8
3、编写原型文件 htestproto.def
string htest(string str)
4、进入php源码包 ext目录, 执行
./ext_skel --extname=htest --proto=htestproto.def
5、vim htest/config.m4, 去除10-12 行dnl
10 PHP_ARG_WITH(htest, for htest support, 11 Make sure that the comment is aligned: 12 [ --with-htest Include htest support])
6、vim htest/htest.c 实现函数
PHP_FUNCTION(htest)
{
        char *str = NULL;
        int argc = ZEND_NUM_ARGS();
        int str_len;
        char *result;
        if (zend_parse_parameters(argc TSRMLS_CC, "s", &str, &str_len) == FAILURE)
                return;
        str_len = spprintf(&result, 0, "%s==", str);
        RETURN_STRINGL(result, str_len, 0);
} 
7、编译
    /usr/local/php/bin/phpize
    ./configure --with-php-config=/usr/local/php/bin/php-config
make & make install
8、拷贝htest.so 文件到 php安装目录 的extensions目录
添加extension = htest.so 到php.ini 中
9、测试
标签:style io ar 使用 for sp 文件 on cti
原文地址:http://my.oschina.net/u/195896/blog/341402