在下一个循环开始之前,在循环完成时从PHP调用函数吗?

I am looping through database row results, creating a PDF with the createPDF function below which in turn calls an email function. I am trying to understand whether these processes will run synchronously (waiting for each function to finish before the next loop begins), or whether I am creating a situation where too many processes end up running at once (exceeding memory limit etc.) if the there are many rows to process.

while ($row = mysqli_fetch_assoc($result)) {
    global $firstname;
    $firstname = $row["first"];
    global $email;
    $email = $row["email"];
    createPDF(); // Calls function to send PDF by email when completed
}

What is the best practice for this scenario?

It depends on how PDF creation looks like. If it forks an external process without waiting for it to finish - then yes, you may have many processes running in parallel and overloading the system.