编程语言
首页 > 编程语言> > php中的Throwables和ParseError

php中的Throwables和ParseError

作者:互联网

<?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

 

标签:customer,handling,Throwables,ParseError,echo,cleanup,Address,Throwable,php
来源: https://www.cnblogs.com/aguncn/p/11176500.html