首页 > 解决方案 > Codeigniter 控制器错误警告。未定义的函数数据库项和声明兼容

问题描述

我正在处理我在线下载的脚本,但是当我安装 codeigniter 时,它会带来这个。

 Severity: Warning

Message: Declaration of MY_Lang::line($line = '') should be compatible with CI_Lang::line($line, $log_errors = true)

Filename: core/MY_Lang.php

Line Number: 41

这是我的控制器

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

class MY_Lang extends CI_Lang {

    // --------------------------------------------------------------------

    /**
     * Load a language file
     *
     * @access  public
     * @param   mixed   the name of the language file to be loaded. Can be an array
     * @param   string  the language (english, etc.)
     * @param   bool    return loaded array of translations
     * @param   bool    add suffix to $langfile
     * @param   string  alternative path to look for language file
     * @return  mixed
     */
    function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $log_errors = TRUE, $alt_path = '', $line ='')
    {       
        parent::load($langfile, $idiom, $return, $add_suffix, $alt_path, $log_errors, $line);
    }

    function get_array()
    {
        return $this->language;
    }

    function line($line = '')
    {
        $value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];

        // Because killer robots like unicorns!
        if ($value === FALSE)
        {
            log_message('debug', 'Could not find the language line "'.$line.'"');
        }

        return $value;
    }

}

我不知道哪里错了,我已经刹车了一些致命的错误警告,但是这个有我的干货。

另一方面,让我感到震惊的第二个错误是

Message: Call to undefined function config_db_item()

Filename: /home/casabla6/public_html/application/core/MY_Loader.php

在控制器中我有这个。

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

class MY_Loader extends CI_Loader
{
   function __construct()
   {
      parent::__construct();

      $this->_ci_view_paths += array(FCPATH.'templates/'=>TRUE);
   }

    public function view($view, $vars = array(), $return = FALSE)
    {
        $admin_template = '';
        if( config_db_item ('admin_template') !== FALSE)
            $admin_template = config_db_item('admin_template');


        if(strpos($view, 'admin/') === 0)
            $view = $admin_template.'/'.$view;

        if(isset($vars['subview']))
        {
            if(strpos($vars['subview'], 'admin/') === 0)
                $vars['subview'] = $admin_template.'/'.$vars['subview'];
        }

        return parent::view($view, $vars, $return);
    }

    function common_view($view, $vars = array(), $return = FALSE)
    {
        $view = 'common/'.$view;

        return parent::view($view, $vars, $return);
    }

}

?>

你能帮帮我吗?

标签: phpcodeigniterserverhosting

解决方案


您的类MY_Lang扩展CI_Lang了,这意味着该方法MY_Lang::line()应该有一个与该方法匹配的定义CI_Lang::line()

中的原始方法CI_Lang

public function line($line, $log_errors = true)

您的扩展名MY_Lang

public function line($line = '')

您需要更改代码以采用相同的参数:

public function line($line, $log_errors = true)

推荐阅读