How to add methods dynamically

后端 未结 8 1350
故里飘歌
故里飘歌 2021-01-01 15:15

I\'m trying to add methods dynamically from external files. Right now I have __call method in my class so when i call the method I want, __call inc

8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-01 15:59

    if i read the manual right, the __call get called insted of the function, if the function dosn't exist so you probely need to call it after you created it

    Class myClass
    {
        function __call($name, $args)
        {
            require_once($name.".php");
            $this->$name($args);
        }
    }
    

提交回复
热议问题