- var_dump: documentation ( source)
<?php
class ThrowsError {
public $name = 'unnamed';
public function __construct($name) {
$this->name = $name;
throw new \Exception("I blew up the constructor of '$name'\n");
}
}
$emptyVar = null;
$obj = (object)array('number' => 1);
try {
$emptyVar = new ThrowsError('emptyVar');
} catch (\Exception $e) {
print($e->getMessage());
}
try {
$obj = new ThrowsError('obj');
} catch (\Exception $e) {
print($e->getMessage());
}
try {
$notPreviouslyDefined = new ThrowsError('notPreviouslyDefined');
} catch (\Exception $e) {
print($e->getMessage());
}
var_dump($emptyVar);
var_dump($obj);
var_dump($notPreviouslyDefined);