当使用错误的控制器名称时,代码点火器error

编程入门 行业动态 更新时间:2024-10-04 05:36:25
当使用错误的控制器名称时,代码点火器error_404页面设计未显示(code-igniter error_404 page design is not showing when using wrong controller name)

IN代码点火器error_404页面设计在hmvc中正常工作,当我使用错误的函数名称,但是当我在hmvc节中使用错误的控制器名称时,它显示空白页面。下面我提到了两种url类型,其中我得到了error_404。 PHP设计。 1)错误页面设计正在处理这种类型的网址

http://localhost/projectName/moduleName/ControllerName/wrongFunctionName

2)空白页面显示这种类型的网址

http://localhost/projectName/moduleName/incorrectControllerName

IN code-igniter error_404 page design is working properly in hmvc when i use a wrong function name but when i am using wrong controller name in hmvc section its showing a blank page.below i mention the both url type in which i get the error_404.php design . 1)error page design is working with this type url

http://localhost/projectName/moduleName/ControllerName/wrongFunctionName

2)blank page is showing with this type of url

http://localhost/projectName/moduleName/incorrectControllerName

最满意答案

以下是我的做法:

在config / routes.php中设置一个404覆盖:

$route['404_override'] = 'utils/page_not_found';

创建一个模块utils和一个控制器Page_not_found.php,用于加载404视图或布局。 这只是一个例外。

在你的索引中使用:

public function index() { $this->output->set_status_header('404'); // setting header to 404 // ... more code }

Here's how I do it:

Set an 404 override in config/routes.php:

$route['404_override'] = 'utils/page_not_found';

Create a module utils and a controller Page_not_found.php that loads your 404 view or layout. It is just an example off course.

In your index use:

public function index() { $this->output->set_status_header('404'); // setting header to 404 // ... more code }

更多推荐

本文发布于:2023-08-07 13:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464095.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:点火器   控制器   错误   名称   代码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!