- var_dump: documentation ( source)
- implode: documentation ( source)
<?php
$errors =
new class {
protected $errors = [];
function __toString() : string {
return
EOL . "Problems: ========================" . EOL . EOL .
implode(EOL, $this->errors) . EOL
;
}
function __count() : int { return count($this->errors); }
function add(string $error){ $this->errors[] = $error; }
function all() : array { $this->errors; }
}
;
var_dump(count($errors));
var_dump($errors);