文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>PHP5实现构造方法重载一法

PHP5实现构造方法重载一法

时间:2007-06-29  来源:liuxingyuyuni


?php
class OverloadTest{
   function __construct()
   {
     $arr=func_get_args();
     switch(func_num_args())
     {
     case 1:
     $this->cons1($arr[0]);
     break;
     case 2:
     $this->cons2($arr[0],$arr[1]);
     break;
      }
   }
    function cons1($var)
    {
       echo "cons1(".$var.") called.";
    }
    function cons2($var1,$var2)
    {
       echo "cons2(".$var1.",".$var2.") called.";
    }
}
$foo = new OverloadTest('x');
$foo2 = new OverloadTest('x',"y");
?>


相关阅读 更多 +
排行榜 更多 +
进击小巨人最新版

进击小巨人最新版

冒险解谜 下载
吞就完了手机版

吞就完了手机版

冒险解谜 下载
坦克玩具城

坦克玩具城

冒险解谜 下载