What are the best practices for structuring the parameters in a PHP file download function for clarity and efficiency?

When structuring parameters in a PHP file download function, it is best to keep it simple and clear for readability and efficiency. One common practice is to include parameters for the file name, file path, and file type to ensure the function can handle various file downloads. Additionally, using default parameter values can help make the function more flexible and user-friendly.

function downloadFile($fileName, $filePath, $fileType = 'application/octet-stream') {
    // Set headers for file download
    header("Content-Type: $fileType");
    header("Content-Disposition: attachment; filename=$fileName");
    
    // Read the file and output its contents
    readfile($filePath);
}