/ Published in: PHP
Shows how to get the name of the calling function. Use this to implement a log method start.
Expand |
Embed | Plain Text
<?php class Base{ function logMethodStart(){ //var_dump($trace); $method = ''; $data = $trace[1]; $method .= $data['class'].'::'; } $method .= $data['function']; } echo "\n"; } } class Outer extends Base { function mytest(){ $this->logMethodStart(); } } function functest(){ Base::logMethodStart(); } $o = new Outer(); $o->mytest(); functest(); Base::logMethodStart(); ?>
You need to login to post a comment.
