I have a clase Base in PHP for inherit it to many children classes, managing errors into Base class, I try to print in screen where the error occurs, Can I get the child class name to show in the error during the Exception in Base parent Class?
2条回答 默认 最新
dongyuqi3808 2016-01-30 17:59关注Yes you can using get_class()
class Base{ public function printBase(){ echo get_class($this); } } class Ext extends Base{} $ext = new Ext(); $ext->printBase(); //Output: Ext解决 无用评论 打赏 举报