<?php
// 1.php
try {
include '2.php';
} catch (\Error $e) {
echo 'CATCHED: ', PHP_EOL, (string) $e, PHP_EOL;
}
echo 'Running after try...catch...', PHP_EOL;
if (class_exists('app', false)) {
echo 'Running app...', PHP_EOL;
(new app())->run();
}
<?php
// 2.php
class app
{
public function run()
{
try {
$this->throwex();
} catch (Error $e) {
echo $e->getMessage() . ' catched';
}
}
public function throwex()
{
echo 'now ex will be thrown';
int = 10/0;
echo 'throwing was done';
}
}
~$ ~/php70/bin/php -d display_errors=1 -d error_reporting=-1 1.php
CATCHED Error: ParseError: syntax error, unexpected '=' in /tmp/1/2.php:16
Stack trace:
#0 {main}
Running after try...catch...