开发者

What is an alternative method `__call`

Method __call is running when come call to undefined method. I need to trigger when calling any existing method in class, something like __callAll.

The simpliest approach would be calling the method in every method, but I don't like this approach. The uses Zend framework.

Please advise开发者_运维技巧 me how to do it?


What you want isn't possible. The only solution I can think of is the following:

  1. Name all your functions, instead of myfunction, _myfunction.
  2. Implement a __call method that wraps each of the function calls of the class to _myfunction.
  3. Before executing the function, run your own code.

There's simply no other way to do this. I also wouldn't recommend using my way either but rather looking into some good code-design books because I bet what you want to do isn't necessary if you'd just have the right class design approach.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜