PHP8 Phar::addEmptyDir

2024-02-20 09:16 更新

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

Phar::addEmptyDir — 添加一個空目錄到 phar 檔案

說明

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

注意:

此方法需要 將 php.ini 中的 phar.readonly 設(shè)為 0 以適合 Phar 對象. 否則, 將拋出PharException.

通過這個方法,可以創(chuàng)建一個以 dirname 為路徑名的空目錄。 這個方法和 ZipArchive::addEmptyDir() 類似。

參數(shù)

directory

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

返回值

沒有返回值, 失敗時拋出異常(exception)。

示例

示例 #1 一個 Phar::addEmptyDir() 示例

<?php
try {
    $a = new Phar('/path/to/phar.phar');

    $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
}
?>

參見

  • PharData::addEmptyDir() - Add an empty directory to the tar/zip archive
  • Phar::addFile() - 將一個文件從文件系統(tǒng)添加到 phar 檔案中
  • Phar::addFromString() - 以字符串的形式添加一個文件到 phar 檔案


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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號