A few months ago, I have read about a PHP function that is called every time a static method is called, similar to the __construct function that is called when an instance of class is instantiated. However, I can’t seem to find what function takes care of this functionality in PHP. Is there such a function?
A few months ago, I have read about a PHP function that is called
Share
You can play with __callStatic() and do something like this:
Using this code any method that is preceded by ‘_’ will run the static ‘constructor’ first.
This is just a basic example, but you can use
__callStatichowever it works better for you.Good luck!