What is an alternative method `__call`-Collection of common programming errors
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:
- Name all your functions, instead of myfunction, _myfunction.
- Implement a __call method that wraps each of the function calls of the class to _myfunction.
- 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.
Originally posted 2013-11-09 23:30:05.