无法通过codeigniter中的子文件夹加载头文件
无法加载头文件。 my codeigniter的结构 视图->仪表板/admin\u仪表板/dashboard.php 控制器->dashboard.php 现在我有头球了 视图->标题/admin\u标题/header.php 我尝试过使用<?php include('../../header/admin_header/header.php');?>无法通过codeigniter中的子文件夹加载头文件,codeigniter,Codeigniter,无法加载头文件。 my codeigniter的结构 视图->仪表板/admin\u仪表板/dashboard.php 控制器->dashboard.php 现在我有头球了 视图->标题/admin\u标题/header.php 我尝试过使用 谢谢,我认为您不应该执行包含,请尝试加载视图: $this->load->view( 'header/admin_header/header' ); 为控制器创建子文件夹怎么样? 以下是您应该做的: Ex: controllers -
谢谢,我认为您不应该执行
包含
,请尝试加载视图:
$this->load->view( 'header/admin_header/header' );
为控制器创建子文件夹怎么样?
以下是您应该做的:
Ex:
controllers
- test
-- Main.php
然后您应该在config/routes.php
上注册它,只需在newline上添加:
$route['test/(:any)'] = 'test/$1';
现在,您可以访问文件夹
test
中的所有控制器文件,我认为您不应该执行include
,请尝试load view:
$this->load->view( 'header/admin_header/header' );
为控制器创建子文件夹怎么样?
以下是您应该做的:
Ex:
controllers
- test
-- Main.php
然后您应该在config/routes.php
上注册它,只需在newline上添加:
$route['test/(:any)'] = 'test/$1';
现在,您可以访问文件夹
test
中的所有控制器文件,不客气。据我所知,这比我们的include
或require
(使用APPPATH或BASEPATH)要好。我还试图将控制器放在所有需要更改的子文件夹中,这里也面临类似问题。您的url如何?要访问它,您的url必须如下:http://your_site_url/admin/dashboard
controllers->admin->dashboard.php,我添加了$route['admin/(:any)]='admin/$1';到routes.php,但没有加载视图。localhost/your\u site\u url本身没有加载,如果我按路由到localhost/your\u site\u url的方式运行,欢迎使用。据我所知,这比我们的include
或require
(使用APPPATH或BASEPATH)要好。我还试图将控制器放在所有需要更改的子文件夹中,这里也面临类似问题。您的url如何?要访问它,您的url必须如下:http://your_site_url/admin/dashboard
controllers->admin->dashboard.php,我添加了$route['admin/(:any)]='admin/$1';到routes.php,但未加载视图。localhost/your\u site\u url本身未加载,如果我在运行时将其路由到localhost/your\u site\u url