note 100350 added to function.debug-backtrace

From: Date: Sun, 10 Oct 2010 09:07:48 +0000
Subject: note 100350 added to function.debug-backtrace
Groups: php.notes 
Request: Send a blank email to php-notes+get-173111@lists.php.net to get a copy of this message
I find it useful to know if a function is being called. in Java for instance you usually print a line with the functionname and arguments in the beginning of the function. I wanted to achieve the same thing in php thus i wrote the following class: class Debug { private static $calls; public static function log($message = null) { if(!is_array(self::$calls)) self::$calls = array(); $call = debug_backtrace(false); $call = (isset($call[1]))?$call[1]:$call[0]; $call['message'] = $message; array_push(self::$calls, $call); } } include this class before anything else usage: Debug::log($message); at the beginning of your function. write yourself a nice printout of the data; ---- Server IP: 83.137.20.135 Probable Submitter: 213.17.32.103 ---- Manual Page -- http://www.php.net/manual/en/function.debug-backtrace.php Edit -- https://master.php.net/note/edit/100350 Del: integrated -- https://master.php.net/note/delete/100350/integrated Del: useless -- https://master.php.net/note/delete/100350/useless Del: bad code -- https://master.php.net/note/delete/100350/bad+code Del: spam -- https://master.php.net/note/delete/100350/spam Del: non-english -- https://master.php.net/note/delete/100350/non-english Del: in docs -- https://master.php.net/note/delete/100350/in+docs Del: other reasons-- https://master.php.net/note/delete/100350 Reject -- https://master.php.net/note/reject/100350 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173111) next »