Hex 发表于 2014-8-19 15:47:16

似月光 发表于 2014-8-19 15:05
这样的设计不灵活,不强大啊,比如我想 这样子
CI_Controller->My_Controller[/ ...

CI 的扩展性是很强大的,基本上所有功能都不需要修改 CI 源码就可以实现。

Hex 发表于 2014-8-19 15:48:47

popcorner 发表于 2014-8-19 15:42
反馈一个问题,论坛这边貌似有个bug,之前用qq账号注册登录本站不需要输入密码,但未登录久了一旦被锁定, ...

这种情况没遇到过,这个还得跟 Discuz! 反馈下。。。

popcorner 发表于 2014-8-19 15:57:46

Hex 发表于 2014-8-19 15:47
CI 的扩展性是很强大的,基本上所有功能都不需要修改 CI 源码就可以实现。

...
前些天尝试用ci开发了个bt的tracker。bt协议当中会在GET里面直接传入urlencode之后的二进制Infohash,而ci在一开始就把GET过滤了一遍然后还把原始的GET值销毁掉了……
于是controller就没办法获得真实的hash……最后只好改ci了

Hex 发表于 2014-8-19 19:52:03

popcorner 发表于 2014-8-19 15:57
前些天尝试用ci开发了个bt的tracker。bt协议当中会在GET里面直接传入urlencode之后的二进制Infohash,而ci ...

CI 2.0 以后不会销毁 GET。

似月光 发表于 2014-8-22 09:53:56

popcorner 发表于 2014-8-19 15:38
你这种的完全没有必要啊,Front_Controller和Admin_Controller直接放顶层就好了,至于网址上可以通过修改 ...

我想要Admin_Controller和Front_Controller里面有不同的专属共用的功能啊,然后才是真正业务的控制器,这样怎么分层

smallerpig 发表于 2014-8-25 17:27:15

完全是你想复杂了

smallerpig 发表于 2014-8-25 17:37:49

本帖最后由 smallerpig 于 2014-8-25 17:39 编辑

Hex 发表于 2014-8-19 13:38
楼主说对了,继承只能有三层。
测试环境 windows 8.1 WampServer Version 2.5 CI 2.2.0
Apache Version :2.4.9   - DocumentationPHP Version :5.5.12   - Documentation
Server Software:

Apache/2.4.9 (Win64) PHP/5.5.12


appliction/core/My_Controller.php:

<?php
// vim: set expandtab cindent tabstop=4 shiftwidth=4 fdm=marker:
// +----------------------------------------------------------------------+
// | WUXI.SourceCode.Smallerpig                                           |
// +----------------------------------------------------------------------+
// | Copyright (c) 2014, WUXI.SOURCECODE Inc. All rights reserved.      |
// +----------------------------------------------------------------------+
// | Authors: smallerpig. www.smallerpig.com                              |
// |                                                                      |
// +----------------------------------------------------------------------+

/**
* @version1.0
* @author   smallerpig
* @date   
*/
class Console_Controller extends CI_Controller{
         function __construct(){
               parent::__construct();
               echo "Console_Controller</br>";
         }
}


class Test_Controller extends Console_Controller{
         function __construct(){
               parent::__construct();
               echo "Test_Controller</br>";
         }
}






application/controller/welcome.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends Test_Controller {

      /**
         * Index Page for this controller.
         *
         * Maps to the following URL
         *               http://example.com/index.php/welcome
         *      - or -
         *               http://example.com/index.php/welcome/index
         *      - or -
         * Since this controller is set as the default controller in
         * config/routes.php, it's displayed at http://example.com/
         *
         * So any other public methods not prefixed with an underscore will
         * map to /index.php/welcome/<method_name>
         * @see http://codeigniter.com/user_guide/general/urls.html
         */
      public function index()
      {
                echo "welcome";
      }
}





输出结果:localhost/index.php
Console_Controller
Test_Controller
welcome


这不是实现了多层的继承?

Hex 发表于 2014-8-25 20:11:01

smallerpig 发表于 2014-8-25 17:37
测试环境 windows 8.1 WampServer Version 2.5 CI 2.2.0
Apache Version :2.4.9   - DocumentationPHP Ver ...

你这样写当然可以实现多层继承,你这样可以实现100层,因为你都写到一个文件里了。

我的意思是,按照 CI 的风格写控制器的话,只能继承两层。
CI 的风格就是一个控制器一个文件一个类。

似月光 发表于 2014-8-28 10:57:43

smallerpig 发表于 2014-8-25 17:37
测试环境 windows 8.1 WampServer Version 2.5 CI 2.2.0
Apache Version :2.4.9   - DocumentationPHP Ver ...

你这多层继承是纯形式,请问有什么用?你这样继承N层都可以
页: 1 [2]
查看完整版本: CI的控制器 是只能有三层吗?