<?php //Throwables //ParseError try { include 'config.php'; } catch (\ParseError $e) { echo 'ParseError handling'; echo '<br/>'; } class Address { private $customer; public function __construct(Customer $customer) { $this->customer = $customer; } } $customer = new stdClass(); try { $address = new Address($customer); } catch (\Throwable $t) { echo 'Throwable handling'; echo '<br/>'; } finally { echo 'cleanup'; echo '<br/>'; } ?>
输出
ParseError handling Throwable handling cleanup