0

我在这里有我的 php 代码:

    if(empty($_POST) === false)
{
    $required_fields = array('username','password','confirm_password','first_name','email');
        foreach($_POST as $key=>$value)
        {
            if(empty($value) && in_array($key, $required_fields) === true)
            {
                $errors() = 'Fields marked with an asterisk are required';
                break 1;
            }
        }
}

print_r($errors);

我想要做的是显示数组,以便我可以找出我的错误在哪里..但是我的浏览器说Fatal error: Can't use function return value in write context in..它标志着我在这个声明中的致命错误。 $errors() = 'Fields marked with an asterisk are required';

请帮帮我..无论如何这是registration-form.php :)

4

1 回答 1

4

将括号更改为方括号:

$errors[] = 'Fields marked with an asterisk are required';
于 2013-10-06T21:15:01.650 回答