<?php function AddUser($name) { if($name=="张三") { echo "add success"; return true; }else { throw new Exception("添加失败"); } } function updateUser($username) { if($username=="张三") { return true; }else{ throw new Exception("更新失败!"); } } function A(){ try{ $res1=AddUser("hell"); $res2=updateUser("world"); }catch(Exception $ex) { echo "处理失败!错误信息:".$ex->getMessage(); } } A(); ?>
时间: 2024-11-06 17:58:15