|
本帖最后由 seahorse 于 2013-5-14 19:06 编辑
控制器代码如下:
<?php
class Blog extends CI_Controller{
function Blog()
{
parent::__construct();
$this->load->helper('url');
$this->load->helper('form');
}
function index()
{
$data['title'] = "Blog Title";
$data['heading'] = "Blog heading";
//$data['query'] = array('clean house','eat lunch', 'call mom');
$data['query'] = $this->db->get('entries');
$this->load->view('blog_view', $data);
}
function comments()
{
echo "test...";
}
}
?>
视图文件代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$title?></title>
</head>
<body>
<h1><?=$heading?></h1>
<?php foreach($query->result() as $row): ?>
<h3><?=$row->title?></h3>
<p><?=$row->body?></p>
<p><?=anchor('blog/comments/'.$row->id,'Comments');?></p>
<hr>
<?php endforeach; ?>
</body>
</html>
访问首页地址:http://localhost/CodeIgniter_2.1.3/index.php/blog/index
浏览器显示“找不到网页”。
访问anchor函数创建的链接地址:http://localhost/CodeIgniter_2.1.3/index.php/blog/comments/1
浏览器显示“找不到网页”。
routes.php中路由设置如下:
$route['default_controller'] = "blog";
$route['404_override'] = '';
我用的是CodeIgniter_2.1.3,是不是路由设置问题?请指点?
|
|