|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2016-11-10 15:35:41
|
显示全部楼层
我贴个手册上面的那个
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Blogs extends CI_Controller {
- public function index()
- {
- $this->load->view('welcome_message');
- }
-
-
-
-
- public function users()
- {
-
- echo ("url segment1: ");
- echo ($this->uri->segment(1));
- echo "<br><br><br><br>";
- echo ("url segment2: ");
- echo ($this->uri->segment(2));
- echo "<br><br><br><br>";
- echo ("url segment3: ");
- echo ($this->uri->segment(3)); //用于某篇文章内容的ID
- // echo aritle(segment(3)); //此处显示文章
- echo "<br><br><br><br>";
- $this->load->view('welcome_message');
- }
-
- }
复制代码
设置路由 $route['blog/joe'] = 'blogs/users/34';
按照手册上面的理解访问http;//127.0.0.1/index.php/blog/joe 等价于访问=>127.0.0.1/index.php/blog/user/34
程序通过获取segment(3)=>34 用于显示文章, 可实际上这个segment(3) 是个空值,导致无法显示。
所以 http;//127.0.0.1/index.php/blog/joe =>127.0.0.1/index.php/blog/user/34 好像不行吧?
|
|