<?php
error_reporting(-1);
echo "<p>Throw <a href=?standard>standard exception</a> or <a href=?extended>extended exception</a></p>";
class E extends Exception {
function __construct($message) {
parent::__construct($message);
}
}
try {
echo "<p>Preparing to throw exceptions.";
if(isset($_GET['standard'])) {
echo "<p>THrowing standard exception</p>";
throw new Exception("Standard exception");
}
if(isset($_GET['extended'])) {
echo "<p>Throwing extended exception.";
throw new E("Extended exception");
}
}
catch (Exception $e) {
echo "<p>Caught standard exception -> ";
echo $e->getMessage();
}
catch (E $e) {
echo "<p>Caught extended exception -> ";
echo $e->getMessage();
}