1. Go to this page and download the library: Download xp-lang/xp-records library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
uselang\IllegalArgumentException;
record Range(int $lo, int $hi) {
init {
if ($this->lo > $this->hi) {
thrownew IllegalArgumentException('Lower border may not exceed upper border');
}
}
}
// Using the declaration from above:
$r= new Range(1, 10);
// Use https://wiki.php.net/rfc/short_list_syntax (>= PHP 7.1)
[$lo, $hi]= $r();
// Optionally map the members, returns the string "1..10"
$string= $r(fn($lo, $hi) => "{$lo}..{$hi}");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.