if(isset($_SESSION['lang'])){
$_SESSION['lang'] = 'ru';
}
include_once('lang'.$_SESSION['lang'].'.php');
<a href="/lang.php?lang=en">English</a>
<a href="/lang.php?lang=ru">Русский</a>
if(isset($_GET['lang'])){
$_SESSION['lang'] = $_GET['lang'];
}
header('location: /');
<a href="/lang.php?lang=en">En</a>
lang.php:
$lang = $_GET['lang'];
$_SESSION['lang'] = $lang;
header('Location: /'.$lang);
index.php:
if(!isset($_SESSION['lang']) {
$_SESSION['lang'] = 'ru';
}
if(isset($_SESSION['lang']) && $_SESSION['lang'] == 'en') {
header('Location: /en');
}
if(isset($_SESSION['lang'])) { include('/langs/'.$_SESSION['lang'].'.php'); }
<a href="/lang.php?lang=en">En</a>
<a href="/lang.php?lang=pl">Pl</a>
<p><?= $lang['hello'] ?>, <?= $user->username ?></p>
if(isset($_GET['lang'])) {
$_SESSION['lang'] = $_GET['lang'];
}