如何故意创建不同的错误(404、500、419)?Laravel PHP

huangapple go评论53阅读模式
英文:

how to create the different errors (404,500,419) intentionally? Lavravel PHP

问题

我试图将我重定向到位于resources\views\errors的不同 blade 页面,如何创建不同的错误情况:

  • 404
  • 402
  • 419
  • 500
    以测试我的不同页面的设计并查看是否有效。

我尝试了abort("404");abort("419");,但它们将我重定向到404.blade.php

如何模拟其他错误?

您的帮助对我非常有用。

英文:

I am trying to redirect me to my different blade pages located in resources\views\errors
how to create the different error cases

  • 404
  • 402
  • 419
  • 500
    to test the designs of my different pages and see if it works.

I tried abort("404"); or abort("419"); but they sent me to 404.blade.php.

how to simulate the other errors?

Your help will be very useful to me.

答案1

得分: 1

The abort() function takes an integer, not a string. From the documentation:

> Some exceptions describe HTTP error codes from the server. For example, this may be a "page not found" error (404), an "unauthorized error" (401) or even a developer generated 500 error. In order to generate such a response from anywhere in your application, you may use the abort helper:

abort(404); // instead of abort("404");

The API-reference shows that the first parameter should be an integer.

英文:

The abort() function takes an integer, not a string. From the documentation:

> Some exceptions describe HTTP error codes from the server. For example, this may be a "page not found" error (404), an "unauthorized error" (401) or even a developer generated 500 error. In order to generate such a response from anywhere in your application, you may use the abort helper:

abort(404); // instead of abort("404");

The API-reference shows that the first parameter should be an integer.

huangapple
  • 本文由 发表于 2023年4月13日 23:16:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76007128.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定