为什么在这段php代码中会出现致命错误?

为什么在这段php代码中会出现致命错误?,php,Php,获取以下错误。不知道为什么 致命错误:递归调用未定义函数reverse_list_() 您的呼叫是在没有参数的情况下完成的: $list->reverse_list_recursively(); public function reverse_list_recursively($current = NULL) 您的定义采用1个参数: $list->reverse_list_recursively(); public function reverse_list_recursive

获取以下错误。不知道为什么

致命错误:递归调用未定义函数reverse_list_()


您的呼叫是在没有参数的情况下完成的:

$list->reverse_list_recursively();
public function reverse_list_recursively($current = NULL)
您的定义采用1个参数:

$list->reverse_list_recursively();
public function reverse_list_recursively($current = NULL)

我怀疑这可能是个问题。

您的呼叫没有参数:

$list->reverse_list_recursively();
public function reverse_list_recursively($current = NULL)
您的定义采用1个参数:

$list->reverse_list_recursively();
public function reverse_list_recursively($current = NULL)

我怀疑这可能是个问题。

您可以使用
$this
关键字访问同一类函数

在第131行,替换

reverse_list_iteratively($current->next);

解释


reverse_list_iteratively()是一个类函数(并且不是静态的),因此您需要对象来访问此函数,对于可以使用$
this
关键字访问的同一类,您可以使用
$this
关键字访问同一类函数

在第131行,替换

reverse_list_iteratively($current->next);

解释


reverse_list_iteratively()是一个类函数(并且不是静态的),因此您需要对象来访问此函数,对于同一个类,您可以使用$
this
关键字来访问它。在这种情况下,您已经用一个参数定义了函数,但您没有传递任何内容,因此它正在查找参数。你可以试试这个

echo "Reversing the list rec";
$list->reverse_list_recursively(0);
$list->print_list();
echo "\n";

在这种情况下,您已经用一个参数定义了函数,但是您没有传递任何内容,因此它正在查找参数。你可以试试这个

echo "Reversing the list rec";
$list->reverse_list_recursively(0);
$list->print_list();
echo "\n";

我有一个默认值集,当我传递某个东西时,我仍然会得到相同的错误。我有一个默认值集,当我传递某个东西时,我仍然会得到相同的错误。他分配了一个默认值
NULL
他分配了一个默认值
NULL
这很奇怪,你的代码对我来说很好。这很奇怪,你的代码对我来说很好。