我正在编写一个类,我想限制该类的用户仅在类型XXX的类中使用它。如何在PHP中完成此(朋友)功能? 与用户交谈不是一个可行的选择: - )
示例:
class ActionLog{
....
....
....
}
abstract class Controller{ ...}
class BabaController extends Controller{
public function SuperAction(){
$X = new ActionLog();; OK!!!
}
}
class SomeOtherBabaWhichIsNotAController extends SomthingElse{
public function super_nice_function(){
$X = new ActionLog();//WILL CRASHHHH!!!!!!!!!!
}
}