小编Jac*_*ack的帖子

数组和foreach

知道为什么不打印这些错误吗?

// Validate the email
if (preg_match($regex, $email))  
        $errors[] = "Invalid email address";

    // ... and the password
    if (strlen($password) < 4)
        $errors[] = "Password is too short";

    // No errors?   
    if (empty($errors))
    {
        // insert into db

    }

// If there were any errors, show them
if (!empty($errors))
{
    $errors = array();
    foreach ($errors as $error)
    echo '<li>'.$error.'</li>';
}
Run Code Online (Sandbox Code Playgroud)

php

3
推荐指数
1
解决办法
388
查看次数

标签 统计

php ×1