PHP 使用 debug_print_backtrace() 或 debug_backtrace() 打印栈轨迹
<?php
/* 使用debug_print_backtrace() 或 debug_backtrace() 打印栈轨迹 */
function fun1() {
print "Hello world!\n";
fun2();
}
function fun2() {
Class1::fun3();
}
Class Class1 {
static function fun3() {
$class2 = new Class2();
$class2->fun4();
}
}
class Class2 {
function fun4() {
debug_print_backtrace();
$backtrace = debug_backtrace();
echo '<pre>';
print_r($backtrace);
}
}
fun1();
输出:
Hello world!
#0 Class2->fun4() called at [D:\wamp\www\practise\php\phpcookbook\error\track.php.php:17]
#1 Class1::fun3() called at [D:\wamp\www\practise\php\phpcookbook\error\track.php.php:11]
#2 fun2() called at [D:\wamp\www\practise\php\phpcookbook\error\track.php.php:7]
#3 fun1() called at [D:\wamp\www\practise\php\phpcookbook\error\track.php.php:30]
<pre>Array
(
[0] => Array
(
[file] => D:\wamp\www\practise\php\phpcookbook\error\track.php.php
[line] => 17
[function] => fun4
[class] => Class2
[object] => Class2 Object
(
) [type] => ->
[args] => Array
(
)
) [1] => Array
(
[file] => D:\wamp\www\practise\php\phpcookbook\error\track.php.php
[line] => 11
[function] => fun3
[class] => Class1
[type] => ::
[args] => Array
(
)
) [2] => Array
(
[file] => D:\wamp\www\practise\php\phpcookbook\error\track.php.php
[line] => 7
[function] => fun2
[args] => Array
(
)
) [3] => Array
(
[file] => D:\wamp\www\practise\php\phpcookbook\error\track.php.php
[line] => 30
[function] => fun1
[args] => Array
(
)
)
)
参考:
<PHP Cookbook>3'rd
PHP 使用 debug_print_backtrace() 或 debug_backtrace() 打印栈轨迹的更多相关文章
- Java异常的栈轨迹fillInStackTrace和printStackTrace的用法
本文转自wawlian 捕获到异常时,往往需要进行一些处理.比较简单直接的方式就是打印异常栈轨迹Stack Trace.说起栈轨迹,可能很多人和我一样,第一反应就是printStackTrace()方 ...
- 基础知识《十四》Java异常的栈轨迹fillInStackTrace和printStackTrace的用法
本文转自wawlian 捕获到异常时,往往需要进行一些处理.比较简单直接的方式就是打印异常栈轨迹Stack Trace.说起栈轨迹,可能很多人和我一样,第一反应就是printStackTrace()方 ...
- Linux下追踪函数调用,打印栈帧
事情的起因是这样的,之前同事的代码有一个内存池出现了没有回收的情况.也就是是Pop出来的对象没有Push回去,情况很难复现,所以在Pop里的打印日志,跟踪是谁调用了它,我想在GDB调试里可以追踪调用的 ...
- linux内核中打印栈回溯信息 - dump_stack()函数分析【转】
转自:http://blog.csdn.net/jasonchen_gbd/article/details/45585133 版权声明:本文为博主原创文章,转载请附上原博链接. 目录(?)[-] ...
- Atitit java的异常exception 结构Throwable类
Atitit java的异常exception 结构Throwable类 1.1. Throwable类 2.StackTrace栈轨迹1 1.2. 3.cause因由1 1.3. 4.Suppres ...
- Java异常的面试问题及答案-Part 1
本文由 ImportNew - 韩远青 翻译自 Journaldev. Java提供了一个健壮的.面向对象的方法来处理出现异常,称为Java异常处理.我以前写过一篇长文章来介绍Java异常处理,今天我 ...
- 给Lisp程序员的Python简介
给Lisp程序员的Python简介 作者:Peter Norvig,译者:jineslong<zzljlu@gmail.com> 这是一篇为Lisp程序员写的Python简介(一些Pyth ...
- java 异常处理机制(java 编程思想)
一.概念 "异常"这个词有"我对此感到意外"的意思.问题出现了,你也许并不清楚该如何处理,但你的确知道不应该置之不理:你要停下来,看看是不是有别人或在别的地方, ...
- 《Thinking In Java》阅读笔记
<Thinking In Java>阅读笔记 前四章:对象导论. 一切都是对象. 操作符. 控制执行流程 public在一个文件中只能有一个,可以是一个类class或者一个接口interf ...
随机推荐
- Python之路,Day2 - Python基础2
def decode(self, encoding=None, errors=None): """ 解码 """ ""& ...
- 【原创】js中input type=file的一些问题
1.介绍 在开发中,文件上传必不可少,input[type=file] 是常用的上传标签,但是它长得又丑.浏览的字样不能换,但是他长得到底有多丑呢.我们来看看在不同浏览器里的样子吧. <inpu ...
- 【Java EE 学习 35 下】【struts2】【struts2文件上传】【struts2自定义拦截器】【struts2手动验证】
一.struts2文件上传 1.上传文件的时候要求必须使得表单的enctype属性设置为multipart/form-data,把它的method属性设置为post 2.上传单个文件的时候需要在Act ...
- input上传按钮美化
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- x64内核内存空间结构
0x00 前言 本文主要是讨论Windows 7 x64下的内核虚拟地址空间的结构,可以利用WiinDBG调试的扩展命令"!CMKD.kvas"来显示x64下的内核虚拟地址空间的整 ...
- linux 自编软件运行时权限不足问题
在非根目录下" ./*.out " 文件时出现显示运行的权限不足的问题,经过调查,有人给出方案: 方案1: 在Linux下执行一个文件时候提示“权限不够”的解决办法如下 转到那个文 ...
- 【CentOS】正则表达式
1.grep [-cinvABC] 'word' filename -c :打印符合要求的行数 --color:显示颜色 -i :忽略大小写(ignore) -n :在输出符合要求的行的同时连同 ...
- CustomEvent自定义事件
javascript与HTML之间的交互是通过事件来实现的.事件,就是文档或浏览器窗口发生的一些特定的交互瞬间.通常大家都会认为事件是在用户与浏览器进行交互的时候触发的,其实通过javascript我 ...
- HDU3333 Turing Tree(线段树)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=3333 Description After inventing Turing Tree, 3x ...
- Leetcode First Missing Positive
Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] ...