【发布时间】:2010-04-30 07:42:49
【问题描述】:
好的,我正在尝试将参数放入一个这样调用的函数中:
$parameters['function']($parameters['params']);
这是我需要放入的函数和参数:
$parameters['function'] = 'test_error';
$parameters['params'] = array(0 => $txt['sometext'], 1 => 'critical', 2 => true);
test_error 函数有 3 个参数:
- 要输出的错误
- 字符串值中记录的错误类型(“一般”、“严重”等)。
- 是否应回显。
这是我得到的输出: 这是一个测试错误。ArraycriticalArray1
我知道这个函数可以完美运行,但它只给了我从它返回的第一个参数。我在这里用$parameters['params'] 做错了什么??
编辑:这里是函数:
function test_error($type = 'error', $error_type = 'general', $echo = true)
{
global $txt;
// Build an array of all possible types.
$valid_types = array(
'not_installed' => $type == 'not_installed' ? 1 : 0,
'not_allowed' => $type == 'not_allowed' ? 1 : 0,
'no_language' => $type == 'no_language' ? 1 : 0,
'query_error' => $type == 'query_error' ? 1 : 0,
'empty' => $type == 'empty' ? 1 : 0,
'error' => $type == 'error' ? 1 : 0,
);
$error_html = $error_type == 'critical' ? array('<p class="error">', '</p>') : array('', '');
$error_string = !empty($valid_types[$type]) ? $txt['dp_module_' . $type] : $type;
// Should it be echoed?
if ($echo)
echo implode($error_string, $error_html);
// Don't need this anymore!
unset($valid_types);
}
【问题讨论】:
-
那里我已经用函数编辑了。
标签: php function parameters