2011-07-03 10 views

答えて

2
function get_caller_method() 
{ 
    $traces = debug_backtrace(); 

    if (isset($traces[2])) 
    { 
     return $traces[2]['function']; 
    } 

    return null; 
} 

function echo_parent_func() { 
    echo get_caller_method(); 
} 

function somefunc() { 
    echo_parent_func(); 
} 

somefunc(); //should echo string 'somefunc' 

Source

EDITはあまりにもthis answerが見つかりました:同様の

+1

PHP 5.3のように引数として 'false'を指定して' debug_backtrace'を呼び出すと、速くなります。 –

関連する問題