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

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

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

    function test3()
    {
            


        
8条回答
  •  感动是毒
    2020-11-29 03:13

    If you are really, really brave, you can make it with runkit extension. (http://www.php.net/manual/en/book.runkit.php). You can play with runkit_method_redefine (you can need Reflection also to retrieve method definition) or maybe combination runkit_method_rename (old function) / runkit_method_add (new function which wraps calls to your test1 function and an old function )

提交回复
热议问题