'PHP: Does echo wait until a function ends before echoing?

I'm learning PHP and am going through some source code I found. In it there's an ajax request as follows:

$.post("includes/handlers/ajax_search.php", {query:value, userLoggedIn: user}, function(data) {
    //uses 'data' variable
});

What I'm unsure about is, the below code is in the called function and would appear to call echo multiple times. Does the called ajax function wait for all echoes to concatenate before actually echoing or does it act like a sort of a stream?

Some clarification would be really appreciated? Thanks.

while($row = mysqli_fetch_array($usersReturnedQuery)) {
        $user = new User($con, $userLoggedIn);

        if($row['username'] != $userLoggedIn)
            $mutual_friends = $user->getMutualFriends($row['username']) . " friends in common";
        else 
            $mutual_friends == "";

        echo "<div class='resultDisplay'>
                <a href='" . $row['username'] . "' style='color: #1485BD'>
                    <div class='liveSearchProfilePic'>
                        <img src='" . $row['profile_pic'] ."'>
                    </div>

                    <div class='liveSearchText'>
                        " . $row['first_name'] . " " . $row['last_name'] . "
                        <p>" . $row['username'] ."</p>
                        <p id='grey'>" . $mutual_friends ."</p>
                    </div>
                </a>
            </div>";

    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source