php - 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);
}
}
?>
你能帮帮我吗?
解决方案
您的类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)
推荐阅读
- winapi - 应用程序验证程序在调用 ShellExecuteEx 时报告访问冲突
- javascript - Disable a textbox with a select option
- java - Maven项目中的系统属性始终为空
- html - R将带有html标签的表格保存到excel
- c++ - 如何在 C++ 中打印函数指针的值?
- batch-file - 如何有条件地重命名或覆盖文件副本?
- c# - 跨平台找不到自定义文件夹路径
- python - Using PNGs in Turtle Module
- reactjs - ReactJS- remove HTTP header before redirect
- javascript - JSON.stringify not working with nested array in javascript