- var_dump: documentation ( source)
<?php
class PreviousException extends \Exception {}
class One extends \RuntimeException {
// Just a standard exception
}
class Two extends \RuntimeException{
// An exception with custom constructor parameters
public function __construct($customMessage, PreviousException $e) {
parent::__construct($customMessage . "LOL", $e->getCode(), $e);
}
}
try {
throw new Two('Throwing two, but catch will receive a different class type', new PreviousException());
}
catch (\Exception $e) {
var_dump($e);
}