- var_dump: documentation ( source)
- range: documentation ( source)
<?php
$listBinder = new class () {
private $refs;
function bind(&$p1, &$p2, &$p3) {
$this->refs = [&$p1, &$p2, &$p3];
[$p1, $p2, $p3] = range(4, 6);
}
function change() {
$this->refs[0] = 42;
$this->refs[1] = 'foo';
$this->refs[2] = 'turtles all the way down';
}
};
$list = [null, null, null];
$listBinder->bind(...$list);
var_dump($list);
$listBinder->change();
var_dump($list);