<?phpfunction MethodWithException() { try { throw new Exception("test exception"); } catch (Exception $e) { //实现任意部分处理, //并把错误传给调用方代码 throw $e; }}try { MethodWithException();}catch (Exception $e) { echo $e->getMessage();}