Why does the following script does not work?
$arr = array();
function collect( $array , $val) {
    $array[] = $val;
    return $array;
}
function checkFoo( $s ) {
    $valid = true;
    if ( strlen( $s ) === 0 ) {
        $isValid = false;
        collectFoo( $arr , $s );
    }
    return $valid;
}
function checkBar( $t ) {
    $valid = true;
    if ( strlen( $s ) != 10 ) {
        $isValid = false;
        collectFoo( $arr , $t );
    }
    return $valid;
}
if ( checkFoo( $that ) && checkBar( $this ) ) {
    echo "success"; 
} else {
    print_r( $error );
}
I always get
Notice: Undefined variable: error in /my.php on line 12
where line 12 resembles the second occurrence of collect(...);  
I know that a function can only return one value, but what if a function returns something in a function that returns something? Because collect returns $array inside checkBar that returns $valid.
 
     
     
     
     
    