(PECL rar >= 0.1)
RarEntry::getName — 取得項目的名稱
此函式沒有參數。
傳回項目名稱字串,若發生錯誤則傳回 false
。
版本 | 說明 |
---|---|
PECL rar 2.0.0 | 自 2.0.0 版起,傳回的字串以 Unicode/UTF-8 編碼。 |
範例 #1 RarEntry::getName() 範例
<?php
//即使在非 UTF-8 編碼的頁面中,此範例也是安全的
//對於以 UTF-8 編碼的頁面,呼叫 mb_convert_encoding 是不必要的
$rar_file = rar_open('example.rar') or die("無法開啟 Rar 壓縮檔");
$entry = rar_entry_get($rar_file, 'Dir/file.txt') or die("找不到此項目");
echo "項目名稱: " . mb_convert_encoding(
htmlentities(
$entry->getName(),
ENT_COMPAT,
"UTF-8"
),
"HTML-ENTITIES",
"UTF-8"
);
?>