Php Codeigniter控制器错误警告。未定义的函数db项与声明兼容
我正在编写一个在线下载的脚本,但当我安装codeigniter时,它带来了这一点Php Codeigniter控制器错误警告。未定义的函数db项与声明兼容,php,codeigniter,server,hosting,Php,Codeigniter,Server,Hosting,我正在编写一个在线下载的脚本,但当我安装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 ( ! d
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;
}
}
控制器里有这个
<?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);
}
}
?>
你能帮我一个忙吗?你的类
MY_Lang
扩展了CI_Lang
,这意味着方法MY_Lang::line()
应该有一个与方法CI_Lang::line()匹配的定义
CI_Lang
中的原始方法:
public function line($line, $log_errors = true)
public function line($line = '')
您在MY_Lang中的扩展名:
public function line($line, $log_errors = true)
public function line($line = '')
您需要更改代码以采用相同的参数:
public function line($line, $log_errors = true)
我有一点你说的,你能帮我多一点吗?在哪里,我必须改变什么?当你扩展一个已经有函数的类时,它必须有相同数量和类型的参数。阅读“您需要更改代码以采用相同的参数:。。。您需要在函数参数中包含$log\u errors
(但不需要在函数中使用它),谢谢!很多它起作用了,大约在第二天你知道些什么吗?消息:调用未定义函数config_db_item(),您试图调用的函数不存在。config\u db\u item()
没有在任何地方定义,或者您没有包含定义它的源文件。