zoukankan      html  css  js  c++  java
  • php扩展开发-常量

    //常量在内核中的结构
    typedef struct _zend_constant {
        zval value;
        int flags;
        char *name;
        uint name_len;
        int module_number;
    } zend_constant;
    //常量注册的宏定义
    #define
    REGISTER_NULL_CONSTANT(name, flags) zend_register_null_constant((name), sizeof(name), (flags), module_number TSRMLS_CC) #define REGISTER_BOOL_CONSTANT(name, bval, flags) zend_register_bool_constant((name), sizeof(name), (bval), (flags), module_number TSRMLS_CC) #define REGISTER_LONG_CONSTANT(name, lval, flags) zend_register_long_constant((name), sizeof(name), (lval), (flags), module_number TSRMLS_CC) #define REGISTER_DOUBLE_CONSTANT(name, dval, flags) zend_register_double_constant((name), sizeof(name), (dval), (flags), module_number TSRMLS_CC) #define REGISTER_STRING_CONSTANT(name, str, flags) zend_register_string_constant((name), sizeof(name), (str), (flags), module_number TSRMLS_CC) #define REGISTER_STRINGL_CONSTANT(name, str, len, flags) zend_register_stringl_constant((name), sizeof(name), (str), (len), (flags), module_number TSRMLS_CC)
    //在MINIT函数中定义常量
    //参数说明:
    //1,常量名称,此处只能是字符串,不能是变量
    //2,常量的值
    //3,常量的属性,对应结构体
    zend_constant的int flags。CONST_CS表示区分大小写,CONST_PERSISTENT表示在php运行过程中,长期存在
    PHP_MINIT_FUNCTION(myext)
    {
       REGISTER_STRING_CONSTANT("MYEXT_VERSION",PHP_MYEXT_VERSION,CONST_CS|CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("MYEXT_LONG_ZERO",0,CONST_CS|CONST_PERSISTENT);
        return SUCCESS;
    }
    /*

    var_dump(MYEXT_VERSION);
    var_dump(MYEXT_LONG_ZERO);

    string(3) "1.0"

    int(0)

    */
  • 相关阅读:
    引入C/C++动态库
    Linux新手常用命令
    使用Dotfunsctor
    C#上传数据到HTTP,HTTPS 代码示例
    C#多个泛型约束问题
    创建DataTable与DataGridView进行绑定
    递归迭代vector三种方法实现二路归并排序
    区间贪心算法
    递归和非递归实现二叉树的遍历
    C语言实现全排列和回溯法总结
  • 原文地址:https://www.cnblogs.com/wuhen781/p/6239639.html
Copyright © 2011-2022 走看看