好的,我试着把参数放入一个函数中,这个函数的调用如下:
$parameters['function']($parameters['params']);
下面是我需要放入的函数和参数:
$parameters['function'] = 'test_error';
$parameters['params'] = array(0 => $txt['sometext'], 1 => 'critical', 2 => true);
-
要输出的错误
-
字符串值中记录的错误类型(“常规”、“关键”等)。
-
下面是我得到的结果:
这是一个测试错误。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);
}