A
A
Anton Seredny2019-02-06 14:55:20
PHP
Anton Seredny, 2019-02-06 14:55:20

Why use private static in PHP methods?

Good afternoon!
As far as I understand, the static methods of a class allow themselves to be used without creating an instance of this class. Those. in fact, we can use these methods just like ordinary "functions".
Something like:
MyClass::stati_method()
But often I see that private static methods are used. Why make them private, because then the above example will not work. Help me understand this nuance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Proskurin, 2019-02-06
@smidl

It will work within the class MyClass.

K
Konstantin, 2019-02-08
@derwin

Most often, I observe this behavior in the implementation of the singleton pattern https://refactoring.guru/ru/design-patterns/single...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question