Answer the question
In order to leave comments, you need to log in
Question about static classes?
Quote:
Static classes do not use constructors. Therefore, each static method must do its own dependency checking, and the calling code must initialize all method parameters unless defaults are used.
the calling code must initialize all method parameters
$a = $this->var;
Answer the question
In order to leave comments, you need to log in
There is no concept of a static class. Properties or methods of a class can be static, but not the class itself.
1. A class can have a constructor, regardless of the presence of static methods.
2. A static method does not have access to class properties, so yes, it is necessary to transfer or pull up the dependencies of the method on the class there.
3. A static method cannot be accessed via $this.
PS: in other words - a static method is just a function that can be called without creating an object of that class, and a static property is a "static variable".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question