image_type_to_extension

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

image_type_to_extension取得图像类型的文件后缀

说明

image_type_to_extension(int $image_type, bool $include_dot = true): string|false

根据给定的常量 IMAGETYPE_XXX 返回后缀名。

参数

image_type

IMAGETYPE_XXX 系列常量之一。

include_dot

是否在后缀名前加一个点。默认是 true

返回值

根据指定的图像类型返回对应的后缀名, 或者在失败时返回 false

范例

示例 #1 image_type_to_extension() 示例

<?php
// 创建图像实例
$im = imagecreatetruecolor(100, 100);

// 保存图像
imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG));
imagedestroy($im);
?>

注释

注意:

此函数不需要 GD 图象库。

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top