LonghornPHP 2026

CachingIterator::getCache

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

CachingIterator::getCacheRecuperar el contenido de la caché

Descripción

public function CachingIterator::getCache(): array

Recupera el contenido de la caché.

Nota:

Se debe utilizar el indicador CachingIterator::FULL_CACHE .

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

Un array que contiene los elementos de la caché.

Errores/Excepciones

Lanza una BadMethodCallException cuando no se está utilizando el indicador CachingIterator::FULL_CACHE .

Ejemplos

Ejemplo #1 Ejemplo de CachingIterator::getCache().

<?php
$iterador = new ArrayIterator(array(1, 2, 3));
$caché = new CachingIterator($iterador, CachingIterator::FULL_CACHE);
$caché->next();
$caché->next();
var_dump($caché->getCache());
$caché->next();
var_dump($caché->getCache());
?>

El ejemplo anterior mostrará:

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

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes

There are no user contributed notes for this page.

AltStyle によって変換されたページ (->オリジナル) /