// Load English language file $lang = 'en'; $language_file = __DIR__."/lang/$lang.php"; if (file_exists($language_file)) { require_once($language_file); }
// Display a translated string echo $lang['greeting'];In this example, we are accessing a translation for the 'greeting' key in the loaded language file. The translation is stored in the `$lang` array, which is loaded from the language file. Package library: The php Lang load function is a built-in function in PHP, and does not require any additional package or library. However, there are many libraries and frameworks available that provide additional functionality for working with multi-lingual websites, such as Symfony, Laravel, and gettext.