1. Go to this page and download the library: Download aplia/support 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/ */
use Aplia\Support\Val;
// Any regular value is simply returned
Val::value(5) === 5;
// Closures are called to fetch the actual value
Val::value(function () {
return 5;
}) === 5;
/**
* @property-read string $id
* @property string $version
* @property string $code
*\/
class Topic
{
use \Aplia\Support\Traits\VirtualProperties;
public $name;
protected $_id;
protected $_version;
public function __construct($id, $version, $name)
{
$this->_id = $id;
$this->_version = $version;
$this->name = $name;
}
public function cachedCode()
{
return $this->version !== null ? ($this->_id . '-' . $this->version) : $this->_id;
}
public function propId($id)
{
return $this->_id;
}
public function propVersion()
{
return $this->_version;
}
public function setpropVersion($version)
{
$this->_version = $version;
}
public function unsetpropVersion()
{
$this->_version = null;
}
}
$t = new Topic('english', '1', 'foo');
$t->name; // returns 'foo' (regular property)
$t->id; // returns 'english'
$t->id = 'greek'; // *id* is read-only so this fails
$t->version; // returns '1'
$t->code; // returns 'english-1'
$t->version = '2';
$t->code; // returns 'english-2'
unset($t->version);
$t->code; // returns 'english'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.