Home > Backend Development > PHP Tutorial > PHP怎样获取执行的方法名呢

PHP怎样获取执行的方法名呢

WBOY
Release: 2016-06-23 14:13:27
Original
924 people have browsed it

<?phpclass a {	function set_error() {				var_dump(__FUNCTION__);	}	function get() {		$this->set_error();	}	}$a = new a;$a->get();?>
Copy after login


想实现的功能是   如果get方法里面产生错误就调用set_error设置错误信息。
想在set_error中获取产生错误的方法名。

以上代码,理想的输出是 get。而不是set_error。

问下大侠们有没些好办法获取到get。  set_error传方法名参数的形式暂时不讨论。


回复讨论(解决方案)

不解释好东西

function set_error() {
         
        //var_dump(__FUNCTION__);
         print_r(debug_backtrace());
    }

该知道怎么做了吧

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template