mirror of
https://github.com/php/presentations.git
synced 2026-03-24 07:32:11 +01:00
28 lines
439 B
PHP
28 lines
439 B
PHP
<?php
|
|
class TooLittleException extends Exception {
|
|
private $num;
|
|
|
|
function TooLittleException($num) {
|
|
parent::exception();
|
|
$this->num = $num;
|
|
}
|
|
|
|
function getMessage() {
|
|
return $this->num . " is too small!";
|
|
}
|
|
}
|
|
|
|
|
|
define('NUM', 10);
|
|
try {
|
|
if (NUM < 20) {
|
|
throw new TooLittleException(NUM);
|
|
}
|
|
} catch (TooLittleException $e) {
|
|
echo $e->getMessage();
|
|
echo "\n<br />\nIn file: ";
|
|
echo $e->getFile();
|
|
echo "\n<br />\n";
|
|
}
|
|
?>
|