PHP8 RarEntry::getName

2024-02-24 22:51 更新

(PECL rar >= 0.1)

RarEntry::getName — 获取条目的名称

说明

public RarEntry::getName(): string

返回存档条目的名称(带路径)。

参数 

此函数没有参数。

返回值 

以字符串形式返回条目名称,如果 出错则返回 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"
);

?>


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号