Hello Reader's! if you want to get the name of function and method being called, Then by using PHP you can do this as explain below:-
Lets's see the example as below here we are using the info provided by a php exception, it's an elegant solution:
function GetCallingMethodName(){
$e = new Exception();
$trace = $e->getTrace();
//position 0 would be the line that called this function so we ignore it
$last_call = $trace[1];
print_r($_call);
}
function firstCall($a, $b){
theCall($a, $b);
}
function theCall($a, $b){
GetCallingMethodName();
}
firstCall('lucia', 'php');
And the output will be as is:-
Array
(
[file] => /home/lufigueroa/Desktop/test.php
[line] => 12
[function] => theCall
[args] => Array
(
[0] => lucia
[1] => php
)
)
In the array key 'function' will tell the function and in the key 'args' will tell the number of args or param being passed to this function.
0 Comment(s)