_validate_cache_id

函式
_validate_cache_id ( $object_id )
引數
  • (mixed) $object_id The cache ID to validate.
    Required:
返回值
  • (bool) Whether the given $object_id is a valid cache ID.
定義位置
相關方法
validate_emailwp_validate_auth_cookievalidate_active_pluginswp_validate_site_datavalidate_file
引入
6.3.0
棄用
-

檢查給定的快取 ID 是否為整數或類整數字符串。

`16` 和 `”16″` 被視為有效,其他數字型別和數字字串(`16.3` 和 `”16.3″`)被視為無效。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _validate_cache_id( $object_id ) {
/*
* filter_var() could be used here, but the `filter` PHP extension
* is considered optional and may not be available.
*/
if ( is_int( $object_id )
|| ( is_string( $object_id ) && (string) (int) $object_id === $object_id ) ) {
return true;
}
/* translators: %s: The type of the given object ID. */
$message = sprintf( __( 'Object ID must be an integer, %s given.' ), gettype( $object_id ) );
_doing_it_wrong( '_get_non_cached_ids', $message, '6.3.0' );
return false;
}
function _validate_cache_id( $object_id ) { /* * filter_var() could be used here, but the `filter` PHP extension * is considered optional and may not be available. */ if ( is_int( $object_id ) || ( is_string( $object_id ) && (string) (int) $object_id === $object_id ) ) { return true; } /* translators: %s: The type of the given object ID. */ $message = sprintf( __( 'Object ID must be an integer, %s given.' ), gettype( $object_id ) ); _doing_it_wrong( '_get_non_cached_ids', $message, '6.3.0' ); return false; }
function _validate_cache_id( $object_id ) {
	/*
	 * filter_var() could be used here, but the `filter` PHP extension
	 * is considered optional and may not be available.
	 */
	if ( is_int( $object_id )
		|| ( is_string( $object_id ) && (string) (int) $object_id === $object_id ) ) {
		return true;
	}

	/* translators: %s: The type of the given object ID. */
	$message = sprintf( __( 'Object ID must be an integer, %s given.' ), gettype( $object_id ) );
	_doing_it_wrong( '_get_non_cached_ids', $message, '6.3.0' );

	return false;
}

常見問題

FAQs
檢視更多 >