What are some best practices for handling situations where the same function name needs to be used with different arguments in PHP?

When the same function name needs to be used with different arguments in PHP, one approach is to use function overloading or method overloading. This can be achieved by using conditional statements within the function to check the number or type of arguments passed and execute different logic accordingly.

function exampleFunction() {
    $args = func_get_args();
    
    if(count($args) == 1) {
        // logic for one argument
    } elseif(count($args) == 2) {
        // logic for two arguments
    } else {
        // default logic
    }
}

// Example usage
exampleFunction(1);
exampleFunction(2, 'test');