wpseek.com
WordPress开发者和主题制作者的搜索引擎
wp_is_uuid › WordPress Function
Since4.9.0
已弃用n/a
› wp_is_uuid ( $uuid, $version = null )
| 参数: (2) |
|
| 返回: |
|
| 定义在: |
|
| 文档: |
Validates that a UUID is valid.
源码
function wp_is_uuid( $uuid, $version = null ) {
if ( ! is_string( $uuid ) ) {
return false;
}
if ( is_numeric( $version ) ) {
if ( 4 !== (int) $version ) {
_doing_it_wrong( __FUNCTION__, __( 'Only UUID V4 is supported at this time.' ), '4.9.0' );
return false;
}
$regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/';
} else {
$regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/';
}
return (bool) preg_match( $regex, $uuid );
}