我正在尝试使用代码清除缓存。它抛出了一个错误Trying to access array offset on value of type int
Route::get('/clear-cache', function() {
Artisan::call('cache:clear');
return "Cache is cleared";
});行elseif ('-' === $key[0])中有错误
protected function parse()
{
foreach ($this->parameters as $key => $value) {
if ('--' === $key) {
return;
}
if (0 === strpos($key, '--')) {
$this->addLongOption(substr($key, 2), $value);
} elseif ('-' === $key[0]) {
$this->addShortOption(substr($key, 1), $value);
} else {
$this->addArgument($key, $value);
}
}
}发布于 2020-10-09 18:22:14
键变量现在可能不是数组。您可以显式地将此类型转换为数组
protected function parse()
{
foreach ($this->parameters as $key => $value) {
$key = (array)$key;
if ('--' === $key) {
return;
}
if (0 === strpos($key, '--')) {
$this->addLongOption(substr($key, 2), $value);
} elseif ('-' === $key[0]) {
$this->addShortOption(substr($key, 1), $value);
} else {
$this->addArgument($key, $value);
}
}
}https://stackoverflow.com/questions/64277981
复制相似问题