How to auto call function in php for every other function call

前端 未结 8 1984
夕颜
夕颜 2020-11-29 02:48
Class test{
    function test1()
    {
        echo \'inside test1\';
    }

    function test2()
    {
        echo \'test2\';
    }

    function test3()
    {
            


        
8条回答
  •  天命终不由人
    2020-11-29 03:18

    The only way to do this is using the magic __call. You need to make all methods private so they are not accessable from the outside. Then define the __call method to handle the method calls. In __call you then can execute whatever function you want before calling the function that was intentionally called.

提交回复
热议问题