- var_dump: documentation ( source)
- class_exists: documentation ( source)
- set_error_handler: documentation ( source)
- printf: documentation ( source)
<?php
$foo = <<<PHP
const LOST_CONSTANT_BEFORE = 42;
class Foo {
public function foo() {
// throw notice about deprecated constructor
}
}
const LOST_CONSTANT_AFTER = 42;
PHP;
set_error_handler(function($errno, $errstr) {
throw new Exception($errstr, $errno); // convert error to exception
});
try {
eval($foo);
} catch (Exception $e) {
printf("error %d with message: %s\n", $e->getCode(), $e->getMessage());
}
var_dump(
class_exists('foo'), // exists!
defined('LOST_CONSTANT_BEFORE'), // where is my constant
defined('LOST_CONSTANT_AFTER') // where is my constant
);