简体   繁体   English

获取在PHP中运行函数/类的文件的名称

[英]Get name of file which run function/class in PHP

Is there any way to find out which file runs function/class in PHP. 有没有办法找出哪个文件在PHP中运行函数/类。

I have index.php which includes functions/classes, than it includes other files depending on url. 我有index.php ,其中包含函数/类,而不是包含其他文件,具体取决于url。 I wish to know which file runs function/class for debugging. 我想知道哪个文件运行函数/类进行调试。

For example I have MySql class and I what to know which file used this class. 例如,我有MySql类,我知道哪个文件使用了这个类。

One option is to type the file name in function like $sql->do($cmd,$fileName) , but there are too many files so I can't change all them. 一个选项是在函数中键入文件名,如$sql->do($cmd,$fileName) ,但文件太多,所以我无法更改所有文件。

See debug_backtrace . 请参阅debug_backtrace

In your MySql class you can simply call this function, and trace the call to it's origin. 在MySql类中,您只需调用此函数,并跟踪对其原点的调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM