File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 229229 Z_SET_REFCOUNT_P(z, refcount); \
230230 }
231231
232+ 5,类型转换
233+
234+ convert_to_long(zval *op); //zval -> long
235+ convert_to_double(zval *op); //zval -> double
236+ convert_to_null(zval *op); //zval -> null
237+ convert_to_boolean(zval *op); //zval -> boolean
238+ convert_to_array(zval *op); //zval -> array
239+ convert_to_object(zval *op); //zval -> object
240+
241+ #define convert_to_cstring(op) if ((op)->type != IS_STRING) { _convert_to_cstring((op) ZEND_FILE_LINE_CC); }
242+
243+ #define convert_to_string(op) if ((op)->type != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
244+
245+ ZEND_API double zend_string_to_double(const char *number, zend_uint length);
246+
247+ ZEND_API int zval_is_true(zval *op);
232248
233249
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ static int le_zval1;
5151const zend_function_entry zval1_functions [] = {
5252 PHP_FE (dump_zval_type , DUMP_ZVAL_TYPE_ARGINFO )
5353 PHP_FE (dump_zval_value , DUMP_ZVAL_VALUE_ARGINFO )
54+ PHP_FE (convert_zval , DUMP_ZVAL_VALUE_ARGINFO )
5455 PHP_FE_END /* Must be the last line in zval1_functions[] */
5556};
5657/* }}} */
@@ -215,6 +216,17 @@ PHP_FUNCTION(dump_zval_value)
215216}
216217
217218
219+ PHP_FUNCTION (convert_zval )
220+ {
221+ zval * zv ;
222+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "z" , & zv ) == FAILURE ) {
223+ return ;
224+ }
225+
226+ convert_to_double (zv );
227+ RETURN_ZVAL (zv , 1 , 0 );
228+ }
229+
218230
219231/*
220232 * Local variables:
Original file line number Diff line number Diff line change 2121echo "value: " . dump_zval_value (1.23 ) . "\n" ;
2222//echo "value:". dump_zval_value(array("arr1")) . "\n";
2323
24+
25+ echo convert_zval ("10 " ) . "\n" ;
26+
2427?>
You can’t perform that action at this time.
0 commit comments