所以我得到错误:
"解析错误:语法错误,意外的';',期望在/application/controllers/c_view_users.php的第19行出现T_FUNCTION ".
我不知道为什么。
这是我的控制器:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class C_view_users extends CI_controller {
public function __construct(){
parent::__construct();
}
public function index() {
$data = array();
$this->load->model('m_users');
//$this->load->library('table');
$data['result'] = $this->m_users->get_contents();
$this->load->view('view_users', $data);
}
?>
和模型:
<?php
class m_claims extends CI_model {
function __construct() {
parent::__construct();
//Get CI Instance
//$CI = & get_instance();
//$CI->load->model( EASYPHP_CORE_DIR . 'user_auth' , 'user_auth');
//--------------- Table name, caption and controller ---------------
$this->tableName = "users";
$this->caption = "Users";
$this->controllerName = "c_view_users";
$this->recordsPerPage = 25;
//--------------- Pages and function setup ---------------
$this->add = true;
$this->update = true;
$this->view = true;
$this->printView = true;
$this->delete = true;
$this->allowQuickSearch = true;
function get_contents() {
$this->db->select('*');
$this->db->from('scouts');
$query = $this->db->get();
return $result = $query->result();
}
}
}
}?>
和视图
<table>
<tr>
<th>Content</th>
</tr>
<?php foreach($result as $r): ?>
<tr><?php echo $r->content; ?>
</tr>
<?php endforeach; ?>
</table>
<?php
谁能帮我找出控制器上的错误?我试过排除法,但没有成功。从这里开始,我认为我的语法看起来是正确的。
把你的模型改成这样:
<?php
class m_claims extends CI_model {
function __construct() {
parent::__construct();
//Get CI Instance
//$CI = & get_instance();
//$CI->load->model( EASYPHP_CORE_DIR . 'user_auth' , 'user_auth');
//--------------- Table name, caption and controller ---------------
$this->tableName = "users";
$this->caption = "Users";
$this->controllerName = "c_view_users";
$this->recordsPerPage = 25;
//--------------- Pages and function setup ---------------
$this->add = true;
$this->update = true;
$this->view = true;
$this->printView = true;
$this->delete = true;
$this->allowQuickSearch = true;
}
function get_contents() {
$this->db->select('*');
$this->db->from('scouts');
$query = $this->db->get();
return $result = $query->result();
}
}
?>