Hi I do not speak English (google translator) apologize for the translation, I want to do something like this:
class First_class extends Second_class
{
function first_class_function ()
{
echo $this->second_class_function ();
}
}
class Second_class
{
function second_class_function ()
{
return "function name which call this function" // in this case first_class_function
}
}
Is that possible?
Yes this is possible, use the constant variable __FUNCTION__
or __METHOD__
, this will give you the function name that you used, as you are using a class I'd recommend using the METHOD constant.
function second_class_function () {
return __METHOD__;
}
您可以使用debug_backtrace函数: http ://php.net/manual/en/function.debug-backtrace.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.