(PHP 5 >= 5.2.0, PHP 7, PHP 8)
image_type_to_extension — 取得圖像類(lèi)型的文件后綴
$imagetype
, bool $include_dot
= true
): string
根據給定的常量 IMAGETYPE_XXX
返回后綴名。
imagetype
IMAGETYPE_XXX
系列常量之一。
include_dot
是否在后綴名前加一個(gè)點(diǎn)。默認是 true
。
根據指定的圖像類(lèi)型返回對應的后綴名。
示例 #1 image_type_to_extension() 例子
<?php
// 創(chuàng )建圖像實(shí)例
$im = imagecreatetruecolor(100, 100);
// 保存圖像
imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG));
imagedestroy($im);
?>
注意:
此函數不需要 GD 圖象庫。