There are several ways to create a website with multi languages, today we will see one way. Using PHP + HTML
- Swith between multiple language our websites
https://demos.ideas2code.io/Multi-language-with-PHP/
- PHP7
- HTML5
Let’s set our variable session by languages
index.php
<?php
session_start();
if(isset($_GET[‘lang’])){
$_SESSION[‘lang’] = $_GET[‘lang’];
}
elseif (!$_SESSION[‘lang’]){
$_SESSION[‘lang’] = ‘en’;
}
include (‘lang_’.$_SESSION[‘lang’].’.php’);
?>
Create a language file
lang_en.php
<?php
define(‘your_variable’,’your_value’);
?>
lang_es.php
<?php
define(‘your_variable’,’your_value’);
?>
Official web site php docs:
https://www.php.net/manual/en/function.session-start.php
Free template used from: