i am try to make a multilingual website following this example. i made a folder language and created 2 files the en.php and the gr.php.
here are my files
language/gr.php
<?php
$lang = array(
//nav bar
'nav1' => 'Αρχική',
'nav2' => 'Δυτική Αττική',
'nav3' => 'Εκδηλώσεις',
'nav4' => 'Σύλλογοι',
'nav5' => 'Καταστήματα'
);
?>
language/en.php
<?php
$lang = array(
//nav bar
'nav1' => 'Home',
'nav2' => 'West Attica',
'nav3' => 'News/Events',
'nav4' => 'Associations',
'nav5' => 'Stores'
);
?>
and the ini.php
<?php
session_start();
$allowed_lang = array('gr', 'en');
if (isset($_GET['lang']) === true && in_array($_GET['lang'], $allowed_lang) === true){
$_SESSION['lang'] = $_GET['lang'];
}
include 'language/' . $_SESSION['lang'] . '.php';
?>
when i am try to run it i get this errors
Notice: Undefined index: lang in /home/user/public_html/init.php on line 10
Warning: include(language/.php): failed to open stream: No such file or directory in /home/peerkavlos/public_html/init.php on line 10
Warning: include(): Failed opening 'language/.php' for inclusion (include_path='.:/usr/share/php') in /home/user/public_html/init.php on line 10
tried to echo the $_GET['lang'];
but the results has no value
that means that the $_GET['lang']
is empty
what am i missing guys?