What are the best practices for handling multi-language websites in PHP to ensure user-friendliness and efficiency in language switching?

When handling multi-language websites in PHP, it's important to ensure user-friendliness and efficiency in language switching. One way to achieve this is by using language files to store translations for different languages and implementing a language switcher that allows users to easily switch between languages.

// Include language file based on user selection
$lang = isset($_GET['lang']) ? $_GET['lang'] : 'en';
include_once('languages/'.$lang.'.php');

// Example language file contents for English
// languages/en.php
$lang['welcome_message'] = 'Welcome to our website!';

// Example language file contents for Spanish
// languages/es.php
$lang['welcome_message'] = '¡Bienvenido a nuestro sitio web!';

// Usage in HTML template
echo $lang['welcome_message'];

// Language switcher
echo '<a href="?lang=en">English</a> | <a href="?lang=es">Spanish</a>';