I have a function like this: 

```
function database_connect(){
    $mysqli = new mysqli($_POST['mysql_host'],$_POST['mysql_username'],$_POST['mysql_password']);
    /* check connection */
    if ($mysqli->connect_errno) {
        return FALSE;
    }

    /* check if server is alive */
    if ($mysqli->ping()) {
        return TRUE;
    } else {
        return FALSE;
    }

    /* close connection */
    $mysqli->close();
}

```

Is it legal to place the return keyword not on the end of the function but having it in the middle?

And is it legal to use return more then once in one function?