What is the recommended approach for executing multiple functions in PHP when a link is clicked?

When a link is clicked in PHP, you can use JavaScript to send an AJAX request to a PHP script that executes multiple functions. This approach allows you to handle multiple tasks without reloading the page.

// HTML code with a link that triggers the AJAX request
<a href="#" id="execute-functions">Execute Functions</a>

// JavaScript code to handle the AJAX request
<script>
document.getElementById('execute-functions').addEventListener('click', function() {
    var xhr = new XMLHttpRequest();
    xhr.open('GET', 'execute_functions.php', true);
    xhr.send();
});
</script>

// PHP script (execute_functions.php) that executes multiple functions
<?php
// Function 1
function function1() {
    // Code for function 1
}

// Function 2
function function2() {
    // Code for function 2
}

// Call the functions
function1();
function2();
?>