【发布时间】:2016-12-28 04:28:19
【问题描述】:
我们只有一门课
class A
{
// I am using class B here
public function whatever()
{
$class_b = new B;
$class_b->show_caller();
}
}
其他
class B
{
public function show_caller()
{
// show me the caller class (should output "A")
}
}
我需要获取调用者类名。 附:继承不是一种选择!
【问题讨论】:
-
为什么需要调用者?听起来像是设计缺陷。
-
Print PHP Call Stack的可能重复
-
嗯,我知道架构很糟糕,但是项目很大,我没有时间重构所有这些。我就是不能使用继承。
标签: php