How can the order of function calls impact the execution of code in PHP, specifically when handling form submissions and displaying success messages?

The order of function calls can impact the execution of code when handling form submissions and displaying success messages in PHP. To ensure that the success message is displayed after the form submission has been processed, the form submission processing logic should be executed before displaying the success message.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form submission
    // Insert code here to handle form data
    
    // Display success message after form submission has been processed
    echo "Form submitted successfully!";
}
?>

<!-- HTML form -->
<form method="post" action="">
    <!-- Form fields go here -->
    <input type="submit" value="Submit">
</form>