rest_is_object

函式
rest_is_object ( $maybe_object )
引數
  • (mixed) $maybe_object The value being evaluated.
    Required:
返回值
  • (bool) True if object like, otherwise false.
定義位置
相關方法
rest_sanitize_objectrest_is_booleanget_linkobjectsget_queried_objectget_post_status_object
引入
5.5.0
棄用
-

rest_is_object: 這是一個WordPress的函式,用來檢查一個值是否是一個物件。如果該值是一個物件,該函式返回真,否則返回假: 這個函式是用來驗證和淨化WordPress REST API的輸入資料的。

確定一個給定的值是否是類似物件的。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function rest_is_object( $maybe_object ) {
if ( '' === $maybe_object ) {
return true;
}
if ( $maybe_object instanceof stdClass ) {
return true;
}
if ( $maybe_object instanceof JsonSerializable ) {
$maybe_object = $maybe_object->jsonSerialize();
}
return is_array( $maybe_object );
}
function rest_is_object( $maybe_object ) { if ( '' === $maybe_object ) { return true; } if ( $maybe_object instanceof stdClass ) { return true; } if ( $maybe_object instanceof JsonSerializable ) { $maybe_object = $maybe_object->jsonSerialize(); } return is_array( $maybe_object ); }
function rest_is_object( $maybe_object ) {
	if ( '' === $maybe_object ) {
		return true;
	}

	if ( $maybe_object instanceof stdClass ) {
		return true;
	}

	if ( $maybe_object instanceof JsonSerializable ) {
		$maybe_object = $maybe_object->jsonSerialize();
	}

	return is_array( $maybe_object );
}

常見問題

FAQs
檢視更多 >