【发布时间】:2015-04-16 13:15:18
【问题描述】:
我正在将我的 Codeigniter 从 2.2.1 升级到 3.0.0。很多事情都发生了变化,尤其是会话。
CI 2.2.1 及之前的版本在 system/core/Common.php 中具有以下功能:214 左右的行。
function &get_config($replace = array())
{
static $_config;
if (isset($_config))
{
return $_config[0];
}
这是扩展system/core/Input.php的函数
应用程序/核心/MY_Input.php
Class MY_Input extends CI_Input
{
function _clean_input_keys($str, $fatal = true)
{
$config = &get_config('config');
if ( ! preg_match("/^[".$config['permitted_uri_chars']."]+$/i",
rawurlencode($str)))
{
exit('Disallowed Key Characters.');
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
return $str;
}
}
直到这里一切正常。升级到 CI# 后 system/core/Common.php 已将函数改为: Line around 238
function &get_config(Array $replace = array())
{
static $config;
if (empty($config))
{
如何在 MY_Input.php 中匹配此函数的参数
$config = &get_config('config');
【问题讨论】:
-
您正在提供字符串,而您在函数中提到参数应该是一个数组。这就是它给你错误的原因。
-
@john 它适用于 CI 2.2.1。为什么不使用 CI 3?
-
我不知道 CI,但我知道如果你在函数定义中指定参数类型,那么参数类型在函数调用中应该是相同的。
-
$config 是一个数组。它拉出 config.php。做 var_dump($config) 证实了这一点。
标签: php codeigniter codeigniter-2 codeigniter-url codeigniter-routing