Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将函数名作为类共享_Php_Class - Fatal编程技术网

Php 将函数名作为类共享

Php 将函数名作为类共享,php,class,Php,Class,如果我有 class root_parser extends doc_parser { function xml_parser($filename, &$id) { parent::doc_parser($filename) } } 在我的代码和这个 在包含的文件中 class doc_parser { public function doc_parser( $filename ) {some code here} } 这将运行函数doc_解析器还是只访问类?因为我在使用va

如果我有

class root_parser extends doc_parser {
 function xml_parser($filename, &$id)
{

parent::doc_parser($filename) 
}

}
在我的代码和这个

在包含的文件中

class doc_parser
{
public function doc_parser( $filename )
{some code here}
}
这将运行函数doc_解析器还是只访问类?因为我在使用var_dump时调用了未定义的函数doc_parser(),但它显示在我的回溯中

array_walk(debug_backtrace(),create_function('$a,$b','print "{$a[\'function\']}()(".basename($a[\'file\']).":{$a[\'line\']}); ";'));
我不想运行这个函数,我只想知道它是否会运行这个函数?还有为什么当我回溯代码时会出现

这是我用于回溯的代码

array_walk(debug_backtrace(),create_function('$a,$b','print "{$a[\'function\']}()(".basename($a[\'file\']).":{$a[\'line\']}); ";'));

通过重命名函数或类进行检查,然后查看代码是否有效。如果是,那么您就知道命名是问题所在。

信息不足。输入所有必要的代码。你到底在哪里调用那段代码?你缺少doc_解析器方法的开括号和闭括号。我不想调用那段代码,我只是想知道它是调用函数还是访问类,如果我刚刚that@Toussant土地所有者:“如果我只有那个”-如果你真的只有那个-这是不正确的代码,因为
parent::
在任何类方法之外都没有意义。“我只是想知道它是调用函数还是访问类”——这个短语也没有意义哦,我理解你的意思,我编辑了它,我的意思是如何使用这个parent::part?在这种情况下,使用parent::(string)会运行函数还是只访问类?我这样问是因为在这种情况下,类和该类中的函数共享相同的名称