【发布时间】:2021-08-30 14:50:31
【问题描述】:
我正在使用:
- Laravel 版本:8.35.1
- PHP 版本:7.4.9
在修补程序和路由上,我使用 Str::replace() 方法,就像在 docs 中一样,但出现错误:
带有消息 Method Illuminate\Support\Str::replace 的 BadMethodCallException 不存在。
示例 1:
root@c6dd4af63e3c:/var/www/html# php artisan tinker
Psy Shell v0.10.7 (PHP 7.4.9 — cli) by Justin Hileman
>>> Illuminate\Support\Str::replace('8.x', '9.x', 'Laravel 8.x');
BadMethodCallException with message 'Method Illuminate\Support\Str::replace does not exist.'
>>>
示例2:
Route::get('/test', function () {
return Illuminate\Support\Str::replace('8.x', '9.x', 'Laravel 8.x');
});
为什么会出现此错误以及如何解决?
【问题讨论】: