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:-
We use 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($last_call);
}
function firstCall($a, $b){
theCall($a, $b);
}
function theCall($a, $b){
GetCallingMethodName();
}
firstCall('lucia', 'php');
And the ouptput is:-
Array
(
[file] => /home/lufigueroa/Desktop/test.php
[line] => 12
[function] => theCall
[args] => Array
(
[0] => lucia
[1] => php
)
)
0 Comment(s)