1

I'm into an issue, while running alertError(), it seems to be fine and there is an access for $errors, but while running showErrors(), it tells me that the variable is underfined. "Undefined variable: errors in"

$errors = array();

function alertError($error){
    $errors[] = $error;
    echo $errors[count($errors)-1];
}

function showErrors(){
        echo "<html>
                <head>
                    <title>Error occurred!</title>
                </head>
                <body>";
                foreach($errors as $error){
                    echo $error."<br>";
                }
        echo "
                </body>
             </html>";
    die();
}

Why does alertError() seems to know that $errors is defined, and showErrors() is having trouble accessing him?

4

3 に答える 3