问题:
I have two classes: Action
and MyAction
.我有两个类: Action
和MyAction
。 The latter is declared as:后者声明为:
class MyAction extends Action {/* some methods here */}
All I need is method in the Action
class (only in it, because there will be a lot of inherited classes, and I don't want to implement this method in all of them), which will return classname from a static call.我所需要的只是Action
类中的方法(只在其中,因为会有很多继承的类,我不想在所有这些类中都实现这个方法),它将从静态调用中返回类名。 Here is what I'm talking about:这就是我要说的:
Class Action {
function n(){/* something */}
}
And when I call it:当我调用它时:
MyAction::n(); // it should return "MyAction"
But each declaration in the parent class has access only to the parent class __CLASS__
variable, which has the value “Action”.但是父类中的每个声明只能访问父类__CLASS__
变量,该变量的值为“Action”。
Is there any possible way to do this?有没有可能的方法来做到这一点?