手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆

PHP函数:debug_backtrace()

首页 > PHP >

不知道你的函数在哪里被调用了?没关系。。
不知道你的函数在哪行?哪个方法?哪个参数里被触发?没关系。
请使用 debug_backtrace函数吧。

呵呵,好象广告一样。

看到这个函数,其实是有点意外的,本来是想好好的做一个LOG,然后想用个观察者模式,最初的发现是,如果我不主动将行数、函数名放进参数里,那就很难在处理的时候,得到这些信息,可以让我快带定位。

结果就看到了这个函数:debug_backtrace();

 

Table 1. Possible returned elements from debug_backtrace()

Name Type Description
function string The current function name. See also __FUNCTION__.
line integer The current line number. See also __LINE__.
file string The current file name. See also __FILE__.
class string The current class name. See also __CLASS__
object object The current object.
type string The current call type. If a method call, "->" is returned. If a static method call, "::" is returned. If a function call, nothing is returned.
args array If inside a function, this lists the functions arguments. If inside an included file, this lists the included file name(s).

ChangeLog

 

Version Description
5.1.1 Added the current object as a possible return element.

仔细看看还是挺有必要的,这些参数,对象都非常重要。。
让我很难过的是,看到这些,我还有必要写LOG吗?当然也只是说说,要想让LOG的信息更完整,对于这些取回来的信息,还是需要作进一步处理的



本站采用创作共享版权协议, 要求署名、非商业和保持一致. 本站欢迎任何非商业应用的转载, 但须注明出自"易栈网-膘叔", 保留原始链接, 此外还必须标注原文标题和链接.

Tags: php, debug, trace

« 上一篇 | 下一篇 »

只显示10条记录相关文章

使用PHP得到所有的HTTP请求头 (浏览: 62781, 评论: 3)
我为什么会选用phpstorm (浏览: 52683, 评论: 5)
快速生成目录树 (浏览: 46833, 评论: 7)
通过file_get_contents来Post数据的实例 (浏览: 46401, 评论: 5)
PHP导入导出Excel方法 (浏览: 45214, 评论: 3)
PHP的XSS攻击过滤函数 (浏览: 42719, 评论: 2)
PHP中Eval的作用 (浏览: 41659, 评论: 4)
工具介绍: 让服务器自动从Hg版本库中下载代码 (浏览: 41055, 评论: 0)
超详细:在Mac OS X中配置Apache + PHP + MySQL (浏览: 40379, 评论: 1)
PHP常见错误(二) (浏览: 39778, 评论: 1)

1条记录访客评论

呵呵,之前也看过这个函数,居然忘了。
还是要多用点才能记住。

Post by jackywdx on 2009, January 15, 5:19 PM 引用此文发表评论 #1


发表评论

评论内容 (必填):