PHP8 PharData::addEmptyDir

2024-02-22 11:48 更新

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 2.0.0)

PharData::addEmptyDir — 將一個(gè)空目錄添加到 tar/zip 存檔中

說明

public PharData::addEmptyDir(string $directory): void

使用此方法,將創(chuàng)建一個(gè)帶有路徑的空目錄。 此方法類似于 ZipArchive::addEmptyDir()。dirname

參數(shù) 

directory

要在 phar 存檔中創(chuàng)建的空目錄的名稱

返回值 

無返回值,失敗時(shí)引發(fā)異常。

示例 

示例 #1 A PharData::addEmptyDir() example

<?php
try {
    $a = new PharData('/path/to/my.tar');

    $a->addEmptyDir('/full/path/to/file');
    // demonstrates how this file is stored
    $b = $a['full/path/to/file']->isDir();
} catch (Exception $e) {
    // handle errors here
}
?>

參見 

  • Phar::addEmptyDir() - 添加一個(gè)空目錄到 phar 檔案
  • PharData::addFile() - 將文件系統(tǒng)中的文件添加到 tar/zip 存檔中
  • PharData::addFromString() - 將字符串中的文件添加到 tar/zip 存檔中


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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號