Php 如何获取调用函数的类/方法名
我有一个像这样的“view.php”文件,其中有一个Php 如何获取调用函数的类/方法名,php,Php,我有一个像这样的“view.php”文件,其中有一个render()方法 class view { public function render(){ require 'views/header.php'; require "views/??/??.php";// ??/?? should be name of class/ method in which render() method is called , is their some propert
render()
方法
class view {
public function render(){
require 'views/header.php';
require "views/??/??.php";// ??/?? should be name of class/ method in which render() method is called , is their some property for that like get_class or something else. in below 'home.php' ??/?? should be home/index.
require 'views/footer.php';
}
}
我有一个像这样的控制器home.php
<?php
class home{
public $view;
function __construct{
$this->view = new view;
}
public function index(){
$this->view->render();// in this case ??/?? should be home/index
}
}
?>
我想获取调用render()
方法的类和方法的名称。例如,我尝试了render()方法get_class
,但它不起作用,因为它将给出定义函数的类的名称,即在上面的示例中,如果我使用???=get_class
它将给出类名称view
是的,我可以在render()
中使用参数,但在每个控制器中,我都必须定义参数,但它们是否有任何方式,以便我可以不使用参数来执行操作。?提前感谢可能的副本可能的副本可能的副本可能的副本