- var_dump: documentation ( source)
<?php
class integer {
private $value;
public function __construct(int ...$value)
{
switch (count($value)) {
case 0:
break;
case 1:
$this->value = $value[0];
break;
default:
throw new Exception('Multiple values given.');
}
}
public function __invoke(int ...$value) : int
{
switch (count($value)) {
case 0:
break;
case 1:
$this->value = $value[0];
break;
default:
throw new Exception('Multiple values given.');
}
return $this->value;
}
public function __toString() : int {
return $this->value;
}
}
$testi = new integer();
$testi(2);
$copy = $testi;
var_dump($copy);
echo $testi;