How can PHP be utilized to handle URL parameters for executing specific functions on a webpage?

To handle URL parameters in PHP for executing specific functions on a webpage, you can use the $_GET superglobal array to retrieve the parameters from the URL. By checking the value of the parameter, you can then conditionally execute the desired function based on the parameter value.

<?php
// Check if the parameter 'action' is set in the URL
if(isset($_GET['action'])) {
    // Retrieve the value of the 'action' parameter
    $action = $_GET['action'];

    // Execute specific functions based on the value of the 'action' parameter
    if($action == 'function1') {
        // Call function1
        function1();
    } elseif($action == 'function2') {
        // Call function2
        function2();
    } else {
        // Handle any other actions
        echo 'Invalid action specified';
    }
}

// Define the functions to be executed
function function1() {
    echo 'Function 1 executed';
}

function function2() {
    echo 'Function 2 executed';
}
?>