我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

找到谁在PHP的类中调用方法[重复]

Possible Duplicate:
Find out which class called a method in another class.

Hello everyone,

I have a class and I can't find where his object creates. I mean, can I somehow find out who calls his constructor?

Thanks a lot, Andrey.

use

$trace = debug_backtrace();
echo "<pre>".print_r($trace[1])."</pre>"; 
//see all the displays '1' is the referrer '0' is self
echo $callingfunction = $trace[1]['function'];
echo $callingclass = $trace[1]['class'];

You can use debug_backtrace() or even better a tracer/profiler like Xdebug to gather the information and e.g. KCachegrind to visualize it.

近期文章

  • 加载有时通过PHP“挂起”的页面(Curl)
  • 将货币符号从php发送到flash
  • php函数 - jsp等价
  • 如何从保存的自定义字段中获取数组
  • session_set_save_handler - 为什么这段代码不起作用?
  • 这个日期格式叫什么,我该如何解析它?
  • 如何在论坛上找到ACTIVE MEMBERS的数量?
  • 在Netbeans中为Symfony Php框架启用推进插件
  • 如何使用Zend_Navigation注册非菜单页面?
  • 在SimpleXmlElement上使用xPath获取单个字符串结果
  • 致命错误 - 执行()php 5.2.13
  • mysqli php扩展
  • 这个jquery删除函数?
  • PHP PDO获取结果
  • 我可以用这个陈述吗?
  • 用于解析链接推文的正则表达式
  • PHP / MySQL显示上次更新/最近的日期
  • 我想检查IP地址到相应的主机名和主机名IP范围
  • php电子邮件地址验证不起作用?
  • PHP MySQL日期差异

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华