无论我的命令是什么,它仍然显示为这样。 错误
我会尝试使用 chatgpt 中的以下代码。但没有任何改变。我完全是个初学者,完全不知道
use Illuminate\Support\Facades\Log;
public function refreshNameLookups()
{
$this->nameList = [];
foreach ($this->allRoutes as $route) {
if ($route->getName()) {
$name = $route->getName();
// Log the type of the route name
Log::info('Route name type: ' . gettype($name));
$this->nameList[$name] = $route;
}
}
}
我也在Youtube上搜索过,但似乎没有问题和我的一样。
PHP 错误“TypeError:非法偏移类型”意味着您试图错误地引用数组索引。在这种情况下,
$name
包含一个不能用作数组索引的值(即,一个对象、另一个数组等)。由于 $name
是 $route->getName()
的结果,请查看 getName()
在\Illuminate\Routing\Route
:
公共函数 getName()
{
返回 $this->action['as'] ??空;
}
我会看一下你定义的路由(例如,在你的routes/web.php文件中),问题大多在那里。