方法 Illuminate\Support\Str::replace 不存在

fra*_*sco 2 laravel laravel-8

我在用:

  • Laravel 版本:8.35.1
  • PHP 版本:7.4.9

在 Tinker 和 Routing 上,我使用文档中的Str::replace()方法,但出现错误:

带有消息 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.'
>>> 
Run Code Online (Sandbox Code Playgroud)

示例2:

Route::get('/test', function () {
    return Illuminate\Support\Str::replace('8.x', '9.x', 'Laravel 8.x');
});
Run Code Online (Sandbox Code Playgroud)

为什么会出现此错误以及如何解决?

Joh*_*obo 6

Illuminate\Support\Str::replaceLaravel 版本引入的字符串替换方法v8.41.0

在此处输入图片说明

参考:https : //github.com/laravel/framework/releases/tag/v8.41.0