I've been searching this thing on whole internet but i couldn't find the solution. I want to make a button to switch between English and German languages. I am not quite familiar with PHP but i found a snippet to switch between two languages. But that didn't helped me at all.
Here is the code of that snippet.
<a href="index.php?language=en"> ENGLISH</a>
<a href="index.php?language=de"> GERMAN</a>
<?php
if ( !empty($_GET['language']) ) {
$_COOKIE['language'] = $_GET['language'] === 'en' ? 'en' : 'de';
} else {
$_COOKIE['language'] = 'de';
}
setcookie('language', $_COOKIE['language']);
if ( $_COOKIE['language'] == "en") {
include("headerEn.php");
} else {
include("headerDe.php");
} ?>
Aucun commentaire:
Enregistrer un commentaire