當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


PHP exif_tagname()用法及代碼示例


exif_tagname()函數是PHP中的內置函數,用於獲取索引的標頭名稱。

用法:

string exif_tagname( int $index )

參數:該函數接受單個參數$index,該參數保存標頭名稱。


返回值:成功時此函數返回標頭名稱。

以下示例說明了PHP中的exif_tagname()函數:

範例1:

<?php 
  
for ($i = 0; $i < 300; $i++) { 
  
    // Get the header 
    $header = exif_tagname($i); 
    if ($header != '') { 
        echo "$i is for "
         . exif_tagname($i) . '<br>'; 
    } 
} 
?>

輸出:

11 is for ACDComment
254 is for NewSubFile
255 is for SubFile
256 is for ImageWidth
257 is for ImageLength
258 is for BitsPerSample
259 is for Compression
262 is for PhotometricInterpretation
266 is for FillOrder
269 is for DocumentName
270 is for ImageDescription
271 is for Make
272 is for Model
273 is for StripOffsets
274 is for Orientation
277 is for SamplesPerPixel
278 is for RowsPerStrip
279 is for StripByteCounts
280 is for MinSampleValue
281 is for MaxSampleValue
282 is for XResolution
283 is for YResolution
284 is for PlanarConfiguration
285 is for PageName
286 is for XPosition
287 is for YPosition
288 is for FreeOffsets
289 is for FreeByteCounts
290 is for GrayResponseUnit
291 is for GrayResponseCurve
292 is for T4Options
293 is for T6Options
296 is for ResolutionUnit
297 is for PageNumber

範例2:

<?php 
  
$i = 100; 
$j = 256; 
  
// Call to the checker function 
checkHeader($i); 
checkHeader($j); 
  
// Functiont to check if a header 
// is defined or not 
function checkHeader($index) { 
    $header = exif_tagname($index); 
  
    if($header == '') { 
        echo $index . ':This tag is not defined <br>'; 
     } else { 
        echo $index . ':This tag is for '
             . $header . '<br>'; 
     } 
} 
?>

輸出:

100:This tag is not defined
256:This tag is for ImageWidth

參考: https://www.php.net/manual/en/function.exif-tagname.php



相關用法


注:本文由純淨天空篩選整理自gurrrung大神的英文原創作品 PHP | exif_tagname() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。