Example:
-
index.php
<?php foo(); bar(); print_r(getCalledFunctions(__FILE__));
Print:
array
0 => 'foo'
1 => 'bar'
Question:
Can anyone get me the getCalledFunctions function?
Example:
index.php
<?php
foo();
bar();
print_r(getCalledFunctions(__FILE__));
Print:
array
0 => 'foo'
1 => 'bar'
Question:
Can anyone get me the getCalledFunctions function?
A reasonable solution demonstrated by Stack Overflow is this response a class named Debug
and include it above any file you want to debug.
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);
}
}
Invoke the Debug :: log () method whenever you need it in the first line of the body of your functions.
And finally print as desired the Debug :: calls property information.