【问题标题】:Method Illuminate\Support\Str::replace does not exist方法 Illuminate\Support\Str::replace 不存在
【发布时间】: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');
});

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

【问题讨论】:

    标签: laravel laravel-8


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2022-06-14
      • 2020-11-20
      • 2022-01-22
      • 2020-06-09
      • 2021-04-27
      • 2019-05-25
      • 2020-08-16
      • 2020-08-29
      • 2021-05-27
      相关资源
      最近更新 更多