用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3482|回复: 1
收起左侧

extends 自已的 controller

[复制链接]
发表于 2012-12-15 14:38:32 | 显示全部楼层 |阅读模式
PHP复制代码
 
<?php
class Comm_Controller extends CI_Controller
{
 function __construct()
 {
  parent::__construct();
 }
 
//其它方法
   public function hello_world()
   {
          echo "Hello World";
   }
}
//file under application/controllers
//file name comm.php
 
复制代码

继承这个controller
PHP复制代码
 
<?php
include FCPATH.APPPATH.'controllers/comm.php';
class Myfirstcontroller extends Comm_Controller
{
     public function index()
    {
       $this->hello_world();
     }
}
 
复制代码
发表于 2013-11-6 09:37:03 | 显示全部楼层
感谢  仿照你的我的include 相对路径引入成功了 。include FCPATH.APPPATH.'controllers/comm.php';

我很奇怪 为什么在控制器中 引入上一级的  不能用 include  "../comm.php'"?


本版积分规则