_validate_cache_id()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
_validate_cache_id( mixed $object_id ): bool
Описание
И 16, и "16" считаются допустимыми, а другие числовые типы и числовые строки (16.3 и "16.3") считаются недопустимыми.
Оригинал (английский)
Both 16 and "16" are considered valid, other numeric types and numeric strings (16.3 and "16.3") are considered invalid.
Параметры
$object_id
mixed
обязательный
Возвращаемое значение
bool
Исходный код
wp-includes/functions.php:7362
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;
}
История изменений
| Версия | Описание |
|---|---|
| 6.3.0 | Introduced. |

