1. 定义
//定义PHP常量
REGISTER_STRINGL_CONSTANT("SIMPLE_VERSION", PHP_SIMPLE_VERSION, sizeof(PHP_SIMPLE_VERSION) - 1, CONST_PERSISTENT | CONST_CS);
REGISTER_STRINGL_CONSTANT("SIMPLE_VERSION", PHP_SIMPLE_VERSION, sizeof(PHP_SIMPLE_VERSION) - 1, CONST_PERSISTENT | CONST_CS);
2. 读取
zval *app_path;
MAKE_STD_ZVAL(app_path);
zend_get_constant("APP_PATH", strlen("APP_PATH"), app_path TSRMLS_CC);
RETURN_STRINGL(Z_STRVAL_P(app_path), Z_STRLEN_P(app_path), 1);
zval_ptr_dtor(&app_path);
要先给app_path初始化一个空间,然后再释放。