谁能告诉我这个功能有什么问题?
我编写了这个函数来从 $reg_errors 数组中获取错误,并在同一个脚本中的不同位置使用这些错误。
function testimonialErrors ($reg_errors) {
    if ( !empty($reg_errors) ) {
            foreach ( $reg_errors AS $error) {
                echo "<li>$error</li>";
            }                                       
    }
    return $error; 
}
然后我像这样调用那个函数..
if ( !empty($reg_errors) ) {
    echo '<div class="error">
                <img src="images/error.png" />
                <h3>Errors,</h3>
                <ul>';
                echo testimonialErrors($reg_errors);
        echo '</ul>
            </div>';
}
但是这段代码不起作用。
更新:这是我的新代码
function tesimonialErrors ($reg_errors) {
    if ( !empty($reg_errors) ) {
            foreach ( $reg_errors AS $error) {
                echo "<li>$error</li>";
            }                                       
    }
    return $error; 
}
并这样称呼它
if ( !empty($reg_errors) ) {
    echo '<div class="error">
                <img src="images/error.png" />
                <h3>Errors,</h3>
                <ul>';
                tesimonialErrors($reg_errors);
        echo '</ul>
            </div>';
}