0

我正在使用 CodeIgniter,我一直从配置文件中得到一个错误

A PHP Error was encountered
Severity: Warning
Message: constant() [function.constant]: Couldn't find constant ONLINE
Filename: libraries/co.php
Line Number: 534


A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/baahoot/public_html/Outlaws/system/core/Exceptions.php:185)
Filename: helpers/url_helper.php
Line Number: 542

我不确定我做错了什么这是来自 git hub 的工作代码。我是 php 新手,想看看这在使用 mysql db 的 arvixe 服务器上是如何工作的,有人知道如何解决这种类型的错误吗?

图书馆/co.php 某处:534

function __construct() { 
    $CI =& get_instance(); 
    //$CI->form_validation->set_error_delimiters( '<br /><div class="response error-note">Error: ', '</div>' ); 
    if(constant('ONLINE') == FALSE): 
        //$CI->output->enable_profiler(TRUE); endif; 
    if(1 == 0 && constant('ONLINE') == TRUE ) { 
        echo $CI->load->view('temporary', '', true); exit; 
    } $CI->load->config('redis'); 
    $this->redis = ($CI->config->item('redis_active')); 
}
4

1 回答 1

1

只需在 word 上使用项目范围的区分大小写搜索ONLINE,任何现代 IDE 甚至编辑器都具有此功能。

查看它的使用位置并查看它是否在某处定义。如果没有 - 查看依赖它的内容并在项目中的某个位置进行定义。它是一个常量,而不是变量,因此它是您在项目中硬编码的一个简单值,因此了解它应该是什么应该没有问题。

您甚至可以尝试将其设置为true,但这只是猜测。如需进一步帮助,请使用方法中的代码更新您的问题

Filename: libraries/co.php
Line Number: 534

编辑:

在您提供代码之后,我建议您只做一个肮脏的 hack,并__construct在开始时将这些行添加到方法中,这样它就会看起来像这样。

function __construct() {
    if(!defined('ONLINE')) {
        define('ONLINE', true);
    }

如果它会抛出错误,请尝试false而不是true. 据我了解,这个常量 iftrue意味着页面正在生产中,如果为 false,则表示页面正在开发中,所以请随意玩。

考虑清理所有代码。

于 2013-09-26T05:38:03.280 回答