WordPress函数:wp_ext2type 根据文件后缀判断文件类型

追格官方小助手/ 2022年06月23日/ WordPress/ 浏览 1310

wp_ext2type 函数,根据文件后缀判断文件类型。


函数原型:


function wp_ext2type( $ext )


函数源码:


function wp_ext2type( $ext ) {
	$ext = strtolower( $ext );

	$ext2type = wp_get_ext_types();
	foreach ( $ext2type as $type => $exts ) {
		if ( in_array( $ext, $exts, true ) ) {
			return $type;
		}
	}
}


可以看到这个函数,用到了 wp_get_ext_types


其原理就是,按表查询。实现原理简单,使用却很方便。

发表评论

暂无评论,抢个沙发...

客服 工单