rest_are_values_equal
函数
rest_are_values_equal ( $value1, $value2 )
- 参数
-
-
(mixed)
$value1
The first value to check.- Required: 是
-
(mixed)
$value2
The second value to check.- Required: 是
-
(mixed)
- 返回值
-
- (bool) True if the values are equal or false otherwise.
- 定义位置
-
-
wp-includes/rest-api.php
, line 1970
-
wp-includes/rest-api.php
- 引入
- 5.7.0
- 弃用
- –
Checks the equality of two values, following JSON Schema semantics.
Property order is ignored for objects.
Values must have been previously sanitized/coerced to their native types.
function rest_are_values_equal( $value1, $value2 ) {
if ( is_array( $value1 ) && is_array( $value2 ) ) {
if ( count( $value1 ) !== count( $value2 ) ) {
return false;
}
foreach ( $value1 as $index => $value ) {
if ( ! array_key_exists( $index, $value2 ) || ! rest_are_values_equal( $value, $value2[ $index ] ) ) {
return false;
}
}
return true;
}
if ( is_int( $value1 ) && is_float( $value2 )
|| is_float( $value1 ) && is_int( $value2 )
) {
return (float) $value1 === (float) $value2;
}
return $value1 === $value2;
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。