What are the best practices for structuring PHP files to only execute specific functions without running the entire file?

When structuring PHP files to only execute specific functions without running the entire file, one common practice is to use conditional statements to check for a specific parameter or query string in the URL. By checking for this parameter, you can determine which function to execute and prevent other functions from running unnecessarily.

<?php

// Check for a specific parameter in the URL
if(isset($_GET['action']) && $_GET['action'] == 'specific_function') {
    specific_function();
}

// Define the specific function
function specific_function() {
    // Function code here
}

// Other functions in the file
function other_function1() {
    // Function code here
}

function other_function2() {
    // Function code here
}

?>