英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论