【问题标题】:codeigniter, moving to live site, An Error Was Encountered Unable to load the requested file: helpers/colordatedeadline_helper.phpcodeigniter,移动到实时站点,遇到错误无法加载请求的文件:helpers/colordatedeadline_helper.php
【发布时间】:2016-03-25 16:27:39
【问题描述】:

我试图在我在 codeigniter 中构建的应用程序上运行,但它一直告诉我“无法加载请求的文件:helpers/writetolog_helper.php”。

我最初将它们自动加载到配置文件中。

$autoload['helper'] = array('url', 'form', 'cookie', 'ColorDateDeadline', 'CalculateMinTohours', 'WriteToLog');

在那之后我尝试在控制器 __construct 中自动加载它们。

 class Customers extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();
        $this->load->model('customer');
        $this->load->helper('WriteToLog');
    }

WriteToLog 函数包含以下代码:

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

if ( !function_exists('WriteToLog'))
{
    function WriteToLog($message , $error=0 ) {
        $clean_message = trim($message);

        if ($error == 1) {
            $real_message   =   "<span style='color: red;'>" . $clean_message . "</span>\r\n";
        } else {
            $real_message   =   "<span style='color: green;'>" . $clean_message . "</span>\r\n";
        }

        $file_handle = fopen(FCPATH . 'logs/logs.txt', 'a+');
        fwrite($file_handle, $real_message);
        fclose($file_handle);
    }
}

文件结构如下:

-- 帮手 --CalculateMinTohours_helper.php -- WriteToLog_helper.php

我从 3.0.5 文档中获得了实现它的所有方法,但它仍然弹出错误,我是否拼错/大写了什么?此外,该应用程序在 Windows 服务器(XAMPP)上运行良好,但我的 BLuehost 帐户开始向我抛出错误。

编辑:当我删除自动加载时,我可以看到我的登录页面,所以这不是路由问题。

感谢您的任何意见, 罗德尼

【问题讨论】:

  • writetolog_helper.php 或 colordatedeadline_helper.php ?你上传了帮助文件吗?
  • 是的,这两个文件都在我的库文件夹中,都带有驼色外壳。
  • 帮助文件属于 helpers 目录...而不是库目录。
  • 感谢您的输入,但正如我上面所说,它们在帮助目录中
  • 尝试让文件名的第一个字母大写

标签: php codeigniter helpers


【解决方案1】:

帮助文件必须全部为小写字母。所以在我的情况下,我将助手重命名为:writetolog.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-05
    • 2014-01-18
    • 2018-08-25
    相关资源
    最近更新 更多