duanniu4106 2012-07-24 15:49
浏览 26
已采纳

如何从debug_backtrace()访问项目?

In this shortened example:

print_r($foo);

Array
(
    [0] => Array
        (
            [function] => exception_handler
            [class] => LP
            [type] => ::
            [args] => Array
                (
                    [0] => Exception Object
                        (
                            [trace:Exception:private] => Array
                                (
                                    [0] => Array
                                        (
                                            [args] => Array
                                                (
                                                    [0] => 'hello'
                                                    [1] => 'world'
                                                )
                                        )
                                )
                        )
                )
        )
)   

How do I access the last item which is "hello".

I am lost after $foo[0]['args'][0]

  • 写回答

2条回答 默认 最新

  • duanmo7075 2012-07-24 15:53
    关注
    [0] => Exception Object
    (
        [trace:Exception:private] => Array
        (
            [0] => Array
            (
                [args] => Array
                (
                    [0] => 'hello'
                    [1] => 'world'
                )
            )
        )
    )
    

    It's an object of type Exception and the values are within a (private) property named trace, thus I guess it's Exception::getTrace()

    $trace = $foo[0]['args'][0]->getTrace();
    echo end($trace[0]['args']);
    

    ... Just realize: You said "last item", but also you said "hello", so know I don't know, what you want. However, $trace[0]['args'] is a regular array and you should be able do with it, whatever you like :) end() gives you the last item.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料