- assert: documentation ( source)
<?php
namespace Test;
class Test
{
private $s;
private $i;
public function __construct(string $s, int $i) {
assert($i > 3000);
$this->s = $s;
$this->i = $i;
}
public function foo()
{
return 's: ' . $this->s . ', i: ' . $this->i;
}
}
try {
$a = new Test('Hello, world!', 2015);
echo $a->foo();
} catch (\Throwable $e) {
echo $e;
}