Answer the question
In order to leave comments, you need to log in
What are the PHP helper class implementation options?
My PHP application needs to use a few simple functions that will need to be called anywhere in the application. What is the best way to implement this in terms of compliance with OOP principles? Guys, please provide code examples or implementation examples.
Answer the question
In order to leave comments, you need to log in
It's hard to reason without having an idea about the functions.
in general, using helpers is not good practice from an OOP point of view. Therefore, if it is possible to avoid creating a helper, it is better to do so. Well, if there is no way to avoid it (for example, you have a helper that provides additional functions for processing arrays), then an ordinary class with a private constructor and static methods ....
"Static" class. Although there is no such concept in PHP, its meaning is in the implementation of static methods.
Implementation of the __callStatic method, which will determine the calls to simple functions, either redefine some of them, or add new ones (well, for example, stripos, depending on the encoding)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question