PHP Conference Japan 2024

CachingIterator::getCache

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

CachingIterator::getCache擷取快取內容

說明

public CachingIterator::getCache(): array

擷取快取的內容。

注意:

必須使用 CachingIterator::FULL_CACHE 旗標。

參數

此函式沒有參數。

回傳值

一個包含快取項目的 array

錯誤/例外

當未使用 CachingIterator::FULL_CACHE 旗標時,拋出 BadMethodCallException

範例

範例 #1 CachingIterator::getCache() 範例

<?php
$iterator
= new ArrayIterator(array(1, 2, 3));
$cache = new CachingIterator($iterator, CachingIterator::FULL_CACHE);

$cache->next();
$cache->next();
var_dump($cache->getCache());

$cache->next();
var_dump($cache->getCache());
?>

上面的範例會輸出

array(2) {
  [0]=>
  int(1)
  [1]=>
  int(2)
}
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

新增註解

使用者貢獻的註解

此頁面沒有使用者貢獻的註解。
To Top