PHP8 RarEntry::getName

2024-02-24 22:51 更新

(PECL rar >= 0.1)

RarEntry::getName — 獲取條目的名稱

說明

public RarEntry::getName(): string

返回存檔條目的名稱(帶路徑)。

參數(shù) 

此函數(shù)沒有參數(shù)。

返回值 

以字符串形式返回條目名稱,如果 出錯則返回 false。

更新日志 

版本說明
PECL rar 2.0.0從版本 2.0.0 開始,返回的字符串以 Unicode/UTF-8 編碼。

示例 

示例 #1 RarEntry::getName() example

<?php

//this example is safe even in pages not encoded in UTF-8
//for those encoded in UTF-8, the call to mb_convert_encoding is unnecessary

$rar_file = rar_open('example.rar') or die("Failed to open Rar archive");

$entry = rar_entry_get($rar_file, 'Dir/file.txt') or die("Failed to find such entry");

echo "Entry name: " . mb_convert_encoding(
    htmlentities(
        $entry->getName(),
        ENT_COMPAT,
        "UTF-8"
    ),
    "HTML-ENTITIES",
    "UTF-8"
);

?>


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號