How can the PHP code be modified to incorporate language selection as part of the URL for better usability and SEO purposes?

To incorporate language selection as part of the URL for better usability and SEO purposes, you can modify the PHP code to detect the language parameter in the URL and set the language accordingly. This can be achieved by using a combination of PHP and htaccess rules to rewrite the URLs.

<?php
// Detect language parameter in URL
if(isset($_GET['lang'])) {
    $language = $_GET['lang'];
} else {
    $language = 'en'; // Default language
}

// Set language for localization
switch($language) {
    case 'en':
        // Load English language file
        break;
    case 'es':
        // Load Spanish language file
        break;
    // Add more cases for other languages
}

// Your PHP code here
?>