- var_dump: documentation ( source)
<?php
class CustomException extends Exception
{
public $object;
public function __construct(string $msg, SomeClass $object)
{
$this->object = $object;
parent::__construct($msg);
}
}
class SomeClass
{
public function __construct()
{
throw new CustomException("Invalid parameters!", $this);
}
}
try {
$a = new SomeClass();
} catch (CustomException $e) {
$a = $e->object;
}
var_dump($a);