- <?php
- class Oss {
- public static function connect() {
- throw new Exception("oss connect error");
- return 'oss object';
- }
- }
- //调用三层
- class S3{
- public static function connect() {
- //throw new Exception("s3 connect error");
- return 's3 object';
- }
- }
- //调用二层
- function callReader($class,$url){
- try{
- $conn=call_user_func_array(array($class, "connect"),array());
- return $conn;
- }catch(Exception $e){
- throw $e;
- }finally{
- //无论如何都会执行,在这记录日志
- }
- }
- //调用一层
- function getMessage(){
- $conn=null;
- try {
- $conn=callReader('Oss',"http://xxxx");
- } catch (Exception $e1) {
- $conn=callReader('S3',"http://xxxx");
- }
- return $conn;
- }
- //最先的入口
- //Vevb.com
- try{
- var_dump(getMessage());
- }catch(Exception $e){}
新闻热点
疑难解答