What are best practices for including language files in PHP scripts and functions?

When including language files in PHP scripts and functions, it is best practice to use constants to define the path to the language files and include them at the beginning of the script or function. This helps maintain code readability and makes it easier to update language files in the future without having to search for hardcoded paths throughout the code.

define('LANG_PATH', '/path/to/language/files/');

function translate($key) {
    include LANG_PATH . 'english.php'; // Include English language file
    // Logic to retrieve translation for $key from language file
    return $translation;
}

echo translate('hello'); // Output: Hello