在 PHP 或 Laravel 中获取 HTTP 状态文本


Get HTTP status text in PHP or Laravel

在Chrome检查器中,当我点击404时,我看到:

Request URL:http://myapp.dev/doesnotexist
Request Method:GET
Status Code:404 Not Found
Remote Address:192.X.X.X:80

到目前为止,我只能通过使用数字代码"404"$exception->getStatusCode()

有没有办法在PHP(或Laravel)中获取"未找到"的文本描述?

您是否将应用程序/配置/应用程序.php更改为:

'debug' => env('APP_DEBUG', true),

如果要显示 Custome 404 错误页面,可以在views/errors目录中创建 404.blade.php 文件。