- get_defined_vars: documentation ( source)
<?php
class ContextException extends RuntimeException {
protected $context = array();
public function __construct($message='', $context=array(), $code=0) {
$this->context = $context;
parent::__construct($message, $code);
}
/**
* Returns an array of variables that existed when exception occured.
* @return array Array of variable name=>value pairs.
*/
public function getContext(){
return $this->context;
}
}
$cheese = true;
throw new ContextException('Something went wrong.', get_defined_vars(), E_NOTICE);