默认控制器是HomePage.php
temp
的index.php
$route['default_controller'] = 'index/home_page';
_layout_home.php
public function home_page()
{
$data['subview']='subview/home_page';
$this->load->view('_layout_home.php',$data);
}
HTML或CSS中没有使用自动对焦属性。
以上代码适用于CodeIgniter网页的主页,从下到上加载。
答案 0 :(得分:0)
第一个字母在类和文件名
上只能是大写
https://www.codeigniter.com/user_guide/general/styleguide.html#file-naming
从
更改文件名HomePage.php // Wrong Way
要
Homepage.php // Correct Way
控制器
https://www.codeigniter.com/user_guide/general/styleguide.html#class-and-method-naming
https://www.codeigniter.com/user_guide/general/views.html#loading-multiple-views
路径应用>控制器> Homepage.php 强>
https://www.codeigniter.com/user_guide/general/controllers.html
<?php
class Homepage extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
}
public function home_page() {
$data['subview']='subview/home_page';
// No need for .php
$this->load->view('layout_home',$data);
}
}
然后在routes.php上
$route['default_controller'] = 'homepage/home_page';
https://www.codeigniter.com/user_guide/general/routing.html#examples
查看
filename layout_home.php
<?php $this->load->view('include/header_home')?>
<?php $this->load->view($subview)?>
<?php $this->load->view('include/footer')?>