时间:2021-07-01 10:21:17 帮助过:5人阅读
try {
$pdo->begintransaction();
foreach ($sql_arr as $sql) {
$stmt = $pdo->exec($sql);
}
$pdo->commit();
return true;
} catch (Exception $e) {
echo $e->getMessage();
$pdo->rollBack();
return false;
}
$res=test('oo');
if($res){
echo '呵呵';
}
function test($name){
try{
a($name);
return true;
}catch (Exception $e){
echo $e->getMessage();
return false;
}
}
function a($name){
if($name=="xx"){
return true;
}else{
throw new Exception("error");
}
}