image_type_to_extension
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
image_type_to_extension — 取得影象型別的檔案後綴
說明
image_type_to_extension(int
$imagetype, bool $include_dot = true): string
根據給定的常量 IMAGETYPE_XXX 返回後綴名。
參數
-
imagetype -
IMAGETYPE_XXX系列常量之一。 -
include_dot -
是否在後綴名前加一個點。預設是
true。
返回值
根據指定的影象型別返回對應的後綴名。
範例
示例 #1 image_type_to_extension() 例子
<?php
// 建立影象實例
$im = imagecreatetruecolor(100, 100);
// 儲存影象
imagepng($im, './test' . image_type_to_extension(IMAGETYPE_PNG));
imagedestroy($im);
?>
註釋
注意:
此函式不需要 GD 圖像庫。