Obtain the upper-layer function name class & nbsp; ex & nbsp; {public & nbsp; function & nbsp; demo () {& nbsp; $ this-& gt; display () ;}public & nbsp; function & nbsp; dispaly () {& nbsp; get the upper-layer function name
Class ex {
Public function demo ()
{
$ This-> display ();
}
Public function dispaly ()
{
// Here, I want to obtain the demo function name for calling this method. what can I do ??
}
}
------ Solution --------------------
Class ex {
Public function demo (){
$ This-> display ();
}
Public function display (){
// Here, I want to obtain the demo function name for calling this method. what can I do ??
Print_r (debug_backtrace ());
}
}
$ P = new ex;
$ P-> demo ();Array
(
[0] => Array
(
[File] => D: \ AMP \ web \ ide_tmp.php
[Line] => 5
[Function] => display
[Class] => ex
[Object] => ex Object
(
)
[Type] =>->
[Args] => Array
(
)
)
[1] => Array
(
[File] => D: \ AMP \ web \ ide_tmp.php
[Line] => 13
[Function] => demo
[Class] => ex
[Object] => ex Object
(
)
[Type] =>->
[Args] => Array
(
)
)
)