php的函数重载请用__set、__get、__call

解决方案 »

  1.   

    这是方法重载,php4下,用以下的方法模拟方法重载。class Myclass { 
    function Myclass() { 
    $name="Myclass".func_num_args(); 
    $this->$name(); 
    //Note that $this->$name() is usually wrong but here 
    //$name is a string with the name of the method to call. 
    } function Myclass1($x) { 
    code; 

    function Myclass2($x,$y) { 
    code; 

    } $obj1=new Myclass(1); //Will call Myclass1 
    $obj2=new Myclass(1,2); //Will call Myclass2
      

  2.   

    __set、__get、__call是php5才支持的magic函数