Answer the question
In order to leave comments, you need to log in
How are functions inherited in PHP?
The single class is a typical singleton.
baseClass inherits the single, it has some functions:
abstract class baseClass extends single
{
public function func1()
{
return __CLASS__;
}
}
class class1 extends baseClass
{
public function func2()
{
$this->func1(); //return - baseClass , а должен, маму его, т.е. папу, т.е. меня за ногу - class1;
echo __CLASS__; // здесь выдаст class1
}
}
Answer the question
In order to leave comments, you need to log in
php.net/manual/ru/language.oop5.late-static-bindin...
functions are not inherited.
> Returns baseClass, I broke my head.
this constant (__CLASS__) returns the name of the class in which you write the called code. If you need an instance type, use get_class($this). It will return exactly the type of instance you are working with.
p.s. Typing code to type names is a bad idea.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question