1. Go to this page and download the library: Download liyuze/php-data-bag library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
//设置单个元素
public function putItem(string $key, string $subKey, mixed $value): void;
//取出单个元素
public function takeItem(string $key, string $subKey): mixed;
//取出单个元素,并丢掉该元素
public function throwItem(string $key, string $subKey): mixed;
//判断指定的一些子元素是否都存在
public function existsItem(string $key, string ...$subKeys): bool;
//判断指定的一些子元素是否至少存在一个
public function existsAnyItem(string $key, string ...$subKeys): bool;
//合并一个或多个新的数组到旧元素上
public function mergeItems(string $key, array ...$arrays): array;
$bag = new DataBag();
$bag->setInspector(new \Liyuze\PhpDataBag\Inspectors\EmptyInspector());
$bag->pickUp('cacheKey', fn ()=>0, new \Liyuze\PhpDataBag\Inspectors\\Liyuze\PhpDataBag\Inspectors\EmptyInspector());