获取当前的类和方法? [英] Get current class and method?

查看:46
本文介绍了获取当前的类和方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个日志功能,该错误功能会将我的错误记录在文件中.

I'm creating a log function that will log my errors in a file.

我认为它将包含发生错误的类和方法.

I thought it will contain which class and method the error occurred in.

有没有一种方法可以记录发生错误的类和方法,所以我不必每次都手动键入它?

Is there a way of logging in which class and method the error occurred in so I don't have to type it manually each time?

推荐答案

我对PHP不太了解,但我相信它具有类似于C/C ++的魔术常数".看看此处:这似乎表明您可以使用

I'm not big on PHP but I believe it has "magic constants" similar to C/C++. Take a look here: This seems to indicate you could use

__LINE__, __FILE__, __FUNCTION__, __CLASS__, and __METHOD__

这篇关于获取当前的类和方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆