I have classes Video and Audio, which extend class Popular
In class, Video & Audio is a function of “public static function parsing ()” are different in themselves
So, as I can from the class of “Popular” address to the class that calls?
That is in a class of “Popular” is a function of “getSong” which has a function call “parsing ()”, but here’s how to call this function from the class that turns ..
Hopefully clearly explained ..
Kind of like the opposite function of need “parent”
class Video extends Popular {
public static function parsing()
{
return 'Videooooooooooooo';
.....
}
public static fuinction tratata()
{
....
}
}
class Audio extends Popular {
public static function parsing()
{
.............
return 'Audio';
.....
}
public static fuinction tratata()
{
....
}
}
class Popular {
public static function getSong()
{
$class = '???????';//Video or Audio???
$class::parsing();// ???
}
}
Sorry for bad english.. used google traslate
There is no need for this behavior.
Put the
parsingfunction in thePopularclass, so thatAudioandVideoinherit it. Then yourgetSongjust looks like this.EDIT:
selfkeyword is bound to the class in which the function is defined. So the below is wrong. The correct answer is to use thestatickeyword instead – IF you are using PHP 5.3.0 or later.below is wrong
But really, getSong is no longer needed. When a base class implementation is called on a child class,
selfstill refers to the child class, so the correctparsingfunction will be called automatically.Did I understand your question correctly?
Also to everyone else: if I’m wrong about this behavior, then shame on me and I need to go back to school. I haven’t used this behavior in a while so I may be rusty.