offsetSet($index, $newval) will change an existing cache value or create a new cache entry
<?php
$cache = new \CachingIterator(
new \ArrayIterator(['a', 'b', 'c', 'd']),
\CachingIterator::FULL_CACHE);
$shortRange = range(0, 1);
foreach ($shortRange as $index) {
$cache->next();
}
echo PHP_EOL . 'The cache' . PHP_EOL;
var_export($cache->getCache());
echo PHP_EOL;
echo $cache->offsetSet('0', 'manual change') . PHP_EOL;
echo $cache->offsetSet('3', 'manual entry') . PHP_EOL;
?>
The cache
array (
0 => 'a',
1 => 'b',
)
The cache
array (
0 => 'manual change',
1 => 'b',
3 => 'manual entry',
)
There is no requirement that the offset exist in the inner iterator, or that the offset exists in the cache.
<?php
$cache = new \CachingIterator(
new \ArrayIterator([]),
\CachingIterator::FULL_CACHE);
echo $cache->offsetSet('22', 'manual entry') . PHP_EOL;
echo PHP_EOL . 'The cache' . PHP_EOL;
var_export($cache->getCache());
echo PHP_EOL;
print_r("cache offset '22' " .
($cache->offsetExists('22') == 1
? 'exists'
: "doesn't exist"
) . PHP_EOL);
?>
The cache
array (
22 => 'manual entry',
)
cache offset '22' exists
PHP.mk документација
CachingIterator::offsetSet
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Патека
cachingiterator.offsetset.php
Локална патека за оваа страница.
Извор
php.net/manual/en
Оригиналниот HTML се реупотребува и локално се стилизира.
Режим
Прокси + превод во позадина
Кодовите, табелите и белешките остануваат читливи во истиот тек.
Референца
cachingiterator.offsetset.php
CachingIterator::offsetSet
Референца за `cachingiterator.offsetset.php` со подобрена типографија и навигација.
CachingIterator::offsetSet
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
CachingIterator::offsetSet — Целта на offsetSet
= NULL
Ги ескејпува специјалните знаци во стринг за употреба во SQL изјава
Оваа функција моментално не е документирана; достапна е само листата со аргументи.
Параметри
key-
The index of the element to be set.
value-
опцијата за конфигурација за времетраењето на скриптата.
key.
Вратени вредности
Не се враќа вредност.
Белешки од корисници 1 белешка
ddrake на dreamingmind точка com ¶
пред 6 години