php函数重载的替代方法--伪重载详解

函数重载的替代方法-伪重载,下面看一个具体的实例代码。

 test1( $_arg [ 0 ] );
   break ;
  case  2 :
   $this -> test2( $_arg [ 0 ] ,  $_arg [ 1 ]);
   break ;
  default :
   $this -> a = 0 ;
   $this -> b = 1 ;
   break ;
  }
 }

 function test1 ($a) {
  $this -> a =  $a ;
 }

 function test2 ($a,  $b) {
  $this -> a =  $a ;
  $this -> b =  $b ;
 }
}
?>

以上所述就是本文的全部内容了,希望大家能够喜欢。

你可能感兴趣的:(php函数重载的替代方法--伪重载详解)