PHP 8.5.0 Released!

Voting

: six plus two?
(Example: nine)

The Note You're Voting On

henzeberkheij at gmail dot com
15 years ago
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:
<?php
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;

<< Back to user notes page

AltStyle によって変換されたページ (->オリジナル) /