codeigniter中的时区设置问题

时间:2011-04-17 12:36:09

标签: php codeigniter-2

我正在尝试使用PHP 5.3.5和2.0.2 CI在我的WAMP上设置CodeIgniter。我的“Hello World”应用程序成功运行(我只有一个控制器和视图)。接下来我添加了一个Model test.php

class Tests extends CI_Model {

    function __construct() {    
        parent::__contruct();
    }
}

我在控制器中将模型实例化为:

$this->load->model('Tests');  

但我一直收到此错误:enter image description here

  

依靠系统的时区设置是不安全的。

如何解决此错误?我尝试在php.ini中设置date.timezone属性。我也尝试在CI的index.php中调用date_default_timezone_set方法。我确实通过了CI论坛,但似乎每个人都通过调用date_default_timezone_set解决了这个问题。但是当我调用该方法时,我甚至没有得到错误。相反,我从Apache获得了500服务器错误响应!

PHP& CI专家..我需要你的帮助。


最新更新

我启用了日志记录,以查看事情是如何在垫子下运行的。这是我的模特:

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

    class Hello extends CI_Model {

        function __construct()
        {
            log_message('debug', "Staring Hello Model");
            parent::__construct();
            log_message('debug', "Done with Hello Model");
        }
    }

我的控制器:

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

class Hello extends CI_Controller {

    public function index()
    {
        //$this->load->view('hello');
        echo phpinfo(); 
    }

    public function newfun()
    {
        log_message('debug', "Starting new method...");
        $this->load->model('hello');
        log_message('debug', "Completed model load...");
        $this->load->view('hello');
    }
}

我的日志文件:

DEBUG - 2011-04-18 15:01:44 --> Config Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Hooks Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Utf8 Class Initialized
DEBUG - 2011-04-18 15:01:44 --> UTF-8 Support Enabled
DEBUG - 2011-04-18 15:01:44 --> URI Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Router Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Output Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Security Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Input Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Global POST and COOKIE data sanitized
DEBUG - 2011-04-18 15:01:44 --> Language Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Loader Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Controller Class Initialized
DEBUG - 2011-04-18 15:01:44 --> Starting new method...
DEBUG - 2011-04-18 15:01:44 --> Model Class Initialized

最后一个日志输出来自ci / system / core文件夹中Model.php的构造函数。没有迹象表明我的模型的控制器正在执行(我没有看到模型的任何日志消息)。

我的模特有什么问题?我是正确编码还是忽略了一些愚蠢的东西?

1 个答案:

答案 0 :(得分:1)

这可能是命名冲突?或命名问题(CI非常具体关于模型/控制器和视图名称中的小写大写)。

你可以尝试'goodbye_model.php'(小写)和模型的主线'类Goodbye_model扩展CI_Model'并加载'Goodbye_model'(首先是大写)。

确保文件名为小写,类名首先是大写。