note 85511 deleted from function.debug-backtrace by tularis

From: Date: Wed, 03 Sep 2008 11:16:41 +0000
Subject: note 85511 deleted from function.debug-backtrace by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-144109@lists.php.net to get a copy of this message
Note Submitter: nyquist dot alexander at gmail dot com ---- Here's a short snippet on how to get the name of the calling class. Example: <?php Class Foo { public static function say() { Bar::say(); } } Class Bar { public static function say() { echo "baz"; $trace = debug_backtrace(); $calling_class = $trace[count($trace)-1]["class"]; echo "Called from: " . $calling_class; } } Foo::say(); ?> Will print "Called from Foo".

« previous php.notes (#144109) next »