Z
Z
zorca2017-09-29 11:53:00
PHP
zorca, 2017-09-29 11:53:00

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

3 answer(s)
M
Maxim Fedorov, 2017-09-29
@zorca

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 ....

A
Anton, 2017-09-29
@Eridani

static in parent class

M
Maxim Kozhin, 2017-09-29
@maximkozhin

"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 question

Ask a Question

731 491 924 answers to any question