遇到 PHP 错误
严重性:通知
消息:数组到字符串的转换
文件名:helpers/form_helper.php
行号:522
这是我的包含表单的视图
<?php
// open the form using CI form helper
echo form_open('loginController', array('id' => 'login'));
// first input field
echo "<div>";
echo form_label('Username', array('for' => 'login_username'));
echo form_input(array(
'type' => 'text',
'name' => 'username',
'id' => 'login_username',
'value' => set_value('username')
));
echo "</div>";
// second input field
echo "<div>";
echo form_label('Password', array('for' => 'login_password'));
echo form_password(array('type' => 'password', 'name' => 'password', 'id' => 'login_password'));
echo "</div>";
// submit button
echo "<div class='submit'>";
echo form_button(array('type' => 'submit', 'content' => 'Log in'));
echo "</div>";
echo "<div class='errors'>";
// display if incorrect username/password
if ($this->session->flashdata('login_error'))
echo 'Incorrect username/password';
// display if incorrect input data
echo validation_errors();
echo "</div>";
// close the form
echo form_close();
?>
这是 PHP 错误中提到的 form_helper.php(第 513 到 537 行)
if ( ! function_exists('form_label'))
{
function form_label($label_text = '', $id = '', $attributes = array())
{
$label = '<label';
if ($id != '')
{
$label .= " for=\"$id\"";
}
if (is_array($attributes) AND count($attributes) > 0)
{
foreach ($attributes as $key => $val)
{
$label .= ' '.$key.'="'.$val.'"';
}
}
$label .= ">$label_text</label>";
return $label;
}
}