How can you display a "Please wait..." message for the script caller in PHP code?
When a script is executing a time-consuming task, it is good practice to display a "Please wait..." message to inform the user that the process is ongoing. This message can be displayed using HTML output in PHP while the script is running. This can be achieved by sending an initial HTML response with the "Please wait..." message, followed by the actual processing of the task.
<?php
// Send the initial HTML response with the "Please wait..." message
echo "Please wait...";
// Perform the time-consuming task
// This can be a database query, file processing, or any other task
// For demonstration purposes, we will use a sleep function to simulate a time-consuming task
sleep(5);
// Once the task is completed, display the result or redirect to another page
echo "Task completed!";
?>