zoukankan      html  css  js  c++  java
  • PHP debug_backtrace() 函数

    PHP Error 和 Logging 函数

    实例

    生成 PHP backtrace:

    <?php
     function a($txt) {
         b("Glenn");
     }
     function b($txt) {
         c("Cleveland");
    }
     function c($txt) {
         var_dump(debug_backtrace());
     }
     a("Peter");
     ?> 
    

    以上代码的输出类似这样:

    Array (
         [0] => Array (
             [file] => C:webfolder	est.php
             [line] => 6
             [function] => c
             [args] => Array (
                 [0] => Cleveland
             )
         )
         [1] => Array (
             [file] => C:webfolder	est.php
             [line] => 3
             [function] => b
             [args] => Array (
                 [0] => Glenn
             )
         )
         [2] => Array (
             [file] => C:webfolder	est.php
             [line] => 11
             [function] => a
             [args] => Array (
                 [0] => Peter
             )
         )
     )
    

    定义和用法

    debug_backtrace() 函数生成 backtrace(回溯跟踪)。

    该函数显示由 debug_backtrace() 函数代码生成的数据。

    返回一个关联数组。可能返回的元素如下:

    名称类型描述
    function string 当前函数名称
    line integer 当前行号
    file string 当前文件名
    class string 当前类名
    object object 当前对象
    type string

    当前调用类型。可能的调用:

    • 返回: "->" - 方法调用
    • 返回: "::" - 静态方法调用
    • 返回 nothing - 函数调用
    args array 如果在函数中,列出函数参数。如果在被引用的文件中,列出被引用的文件名。

    语法

    debug_backtrace(options,limit);
    参数描述
    options

    可选。规定以下选项的位掩码:

    • DEBUG_BACKTRACE_PROVIDE_OBJECT (是否填充 "object" 的索引)
    • DEBUG_BACKTRACE_IGNORE_ARGS (是否忽略 "args" 的索引,包括所有的 function/method 的参数,能够节省内存开销。)
    limit 可选。限制返回堆栈帧的数量。默认为 (limit=0) ,返回所有的堆栈帧。

    技术细节

    返回值: None
    PHP 版本: 4.3+
    PHP 更新日志

    PHP 5.4:添加了可选的参数 limit

    PHP 5.3.6:参数 provide_object 改成 options,并且增加了可选参数 DEBUG_BACKTRACE_IGNORE_ARGS。

    PHP 5.2.5:添加了可选参数 provide_object

    PHP 5.1.1:添加了当前的 object 为可能返回的元素。

  • 相关阅读:
    loadrunner—事务、TPS
    loadrunner—集合点rendezvous
    loadrunner—web_submit_data
    阿里云的docker仓库登陆打标签
    linux 下安装git服务器
    解决mvn clean后打包错:Cannot create resource output directory
    eclipse中创建的spring-boot项目在启动时指定加载那一个配置文件的设置
    docker命令
    springboot所有pom依赖
    pthon小游戏
  • 原文地址:https://www.cnblogs.com/xiaoleiel/p/8324150.html
Copyright © 2011-2022 走看看