时间:2021-07-01 10:21:17 帮助过:19人阅读
if (UNEXPECTED(Z_TYPE_P(op1) != IS_STRING)) {if (Z_ISREF_P(op1)) { op1 = Z_REFVAL_P(op1);if (Z_TYPE_P(op1) == IS_STRING) break;}ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_CONCAT, concat_function);use_copy1 = zend_make_printable_zval(op1, &op1_copy);
bool settype ( mixed &$var , string $type )函数来实现变量类型转化,源码实现如下:
PHP_FUNCTION(settype){ zval *var; char *type; size_t type_len = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs", &var, &type, &type_len) == FAILURE) { return; } ZVAL_DEREF(var); if (!strcasecmp(type, "integer")) { convert_to_long(var); } else if (!strcasecmp(type, "int")) { convert_to_long(var); } else if (!strcasecmp(type, "float")) { convert_to_double(var); } else if (!strcasecmp(type, "double")) { /* deprecated */ convert_to_double(var); } else if (!strcasecmp(type, "string")) { convert_to_string(var); } else if (!strcasecmp(type, "array")) { convert_to_array(var); } else if (!strcasecmp(type, "object")) { convert_to_object(var); } else if (!strcasecmp(type, "bool")) { convert_to_boolean(var); } else if (!strcasecmp(type, "boolean")) { convert_to_boolean(var); } else if (!strcasecmp(type, "null")) { convert_to_null(var); } else if (!strcasecmp(type, "resource")) { php_error_docref(NULL, E_WARNING, "Cannot convert to resource type"); RETURN_FALSE; } else { php_error_docref(NULL, E_WARNING, "Invalid type"); RETURN_FALSE; } RETVAL_TRUE;}
版权声明:本文为博主原创文章,未经博主允许不得转载。