PHP code example of tasoft / value-storage
1. Go to this page and download the library: Download tasoft/value-storage 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/ */
tasoft / value-storage example snippets
use TASoft\Util\ValueStorage;
$vp = new ValueStorage(["value1" => 23]);
$vp->value2 = 44;
$vp["value3"] = 'Hello World';
// The values are fetchable by properties or array access:
echo $vp->value3; // 'Hello World'
echo $vp["value1"]; // 23
use TASoft\Util\ValueStorage;
$vp = new ValueStorage(["test" => $func1 = function() { return 23; }]);
// or
$vp["other-test"] = $func2 = function() { return "Hello World"; };
// You can assign a callback using the constructor, a property name or by array access.
// Fetching the value provider is done by then get() method
echo $func1 === $vp->get('test'); // TRUE
// or
echo $func1 === $vp->test; // TRUE
// And fetching the real value is done by getValue or array access
echo $vp->getValue('test'); // 23
// or
echo $vp["test"]; // 23 !