PHP8 Phar::count

2024-02-20 09:17 更新

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

Phar::count — 返回 Phar 存檔中的條目(文件)數(shù)

說明

public Phar::count(int $mode = COUNT_NORMAL): int

參數(shù) 

mode

mode是一個整數(shù)值,指定要使用的計數(shù)模式。 默認(rèn)情況下,它設(shè)置為 COUNT_NORMAL, 它僅計算存檔中尚未刪除或隱藏的項目數(shù)。 設(shè)置為 COUNT_RECURSIVE 時,它會計算存檔中的所有項目, 包括那些已被刪除或隱藏的內(nèi)容。

返回值 

此 phar 中包含的文件數(shù),或(數(shù)字零) 如果沒有。0

示例 

示例 #1 A Phar::count() example

<?php
// make sure it doesn't exist
@unlink('brandnewphar.phar');
try {
    $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
} catch (Exception $e) {
    echo 'Could not create phar:', $e;
}
echo 'The new phar has ' . $p->count() . " entries\n";
$p['file.txt'] = 'hi';
echo 'The new phar has ' . $p->count() . " entries\n";
?>

以上示例會輸出:

The new phar has 0 entries
The new phar has 1 entries


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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號