开发者

how to have php get the __LINE__ or __FILE__ value where a function is called

开发者 https://www.devze.com 2023-03-30 07:15 出处:网络
I have a ZF debug function like this: function fs_d($d, $at){ if($_REQUEST[\'debug\']==\'123\'){ Zend_Debug::dump($d,\'at: \' . $at);

I have a ZF debug function like this:

function fs_d($d, $at){
    if($_REQUEST['debug']=='123'){
        Zend_Debug::dump($d,'at: ' . $at);
    }else{
        return true;
    }
}

and will call like this:

fs_d($var, $at)

what I'd like $at to represent where $at was called in the function. In other words, something like __FILE__ at __LINE__ that is evaluate开发者_JAVA百科d at point of function call and NOT at point of output. But I don't want to write __FILE__ at __LINE__ at every call.

Is there some way to wrap as a macro, wrap in brackts, {$} or backticks or something?


http://www.php.net/debug_backtrace

$backtrace = debug_backtrace(false);
$last = $backtrace[1];
echo "Error in $last[file], line $last[line] ($last[function])!";
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号