手机浏览 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条记录相关文章

快速生成目录树 (浏览: 48288, 评论: 7)
8年了。。。我的能力还停留在写留言本的技术能力上。。。。 (浏览: 45050, 评论: 3)
PHP的XSS攻击过滤函数 (浏览: 44228, 评论: 2)
PHP中Eval的作用 (浏览: 43052, 评论: 4)
PHP常见错误(二) (浏览: 41317, 评论: 1)
PHP sendmail (浏览: 39241, 评论: 7)
Imagick DLL (浏览: 34572, 评论: 6)
PHP 技巧:file_get_contents的超时处理 (浏览: 31182, 评论: 0)
何为RBAC (浏览: 31128, 评论: 4)
主键和外键的设计原则 (浏览: 31112, 评论: 1)

1条记录访客评论


发表评论

评论内容 (必填):