代码示例一:
// example1
<?php
try{
throw new Exception("Trigger exception first time!");
}catch (Exception $e){
var_dump($e->getMessage());
}finally{
echo "Hello the world!\n";
}
输出:
/mnt/hgfs/SlgCardsServer/example.php:6:
string(29) "Trigger exception first time!"
Hello the world!
代码示例二:
// example2
<?php
try{
throw new Exception("Trigger exception second time!");
}catch (Exception $e){
var_dump($e->getMessage());
return;
}finally{
echo "Hello the world,again!\n";
}
输出:
/mnt/hgfs/SlgCardsServer/example.php:7:
string(30) "Trigger exception second time!"
Hello the world,again!
代码示例三
// example3
try{
throw new Exception("Trigger exception second time!");
}catch (Exception $e){
var_dump($e->getMessage());
exit(0);
}finally{
echo "Hello the world,again!\n";
}
输出:
/mnt/hgfs/SlgCardsServer/example.php:6:
string(30) "Trigger exception second time!"