🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 7.7.3 类型转换 ```c //将原类型转为特定类型,会更改原来的值 ZEND_API void ZEND_FASTCALL convert_to_long(zval *op); ZEND_API void ZEND_FASTCALL convert_to_double(zval *op); ZEND_API void ZEND_FASTCALL convert_to_long_base(zval *op, int base); ZEND_API void ZEND_FASTCALL convert_to_null(zval *op); ZEND_API void ZEND_FASTCALL convert_to_boolean(zval *op); ZEND_API void ZEND_FASTCALL convert_to_array(zval *op); ZEND_API void ZEND_FASTCALL convert_to_object(zval *op); #define convert_to_cstring(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_cstring((op) ZEND_FILE_LINE_CC); } #define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); } //获取格式化为long的值,不会更改原来的值,op类型为zval*,返回值为zend_long #define zval_get_long(op) _zval_get_long((op)) //获取格式化为double的值,返回值double #define zval_get_double(op) _zval_get_double((op)) //获取格式化为string的值,返回值zend_string * #define zval_get_string(op) _zval_get_string((op)) //字符串转整形 ZEND_API int ZEND_FASTCALL zend_atoi(const char *str, int str_len); ZEND_API zend_long ZEND_FASTCALL zend_atol(const char *str, int str_len); //判断是否为true #define zval_is_true(op) \ zend_is_true(op) ```