Good afternoon guys! I’ve been trying to call a function and it just doesn’t seem to work.
So, this is the code I’ve got:
<?
if (!isset($_SESSION)) session_start();
$acess_level = 4;
if (!isset($_SESSION['UserID']) OR ($_SESSION['UserAL'] < $acess_level)) {
session_destroy();
header("Location: login"); exit;
}
$tlang = $_SESSION['lang'];
$level = $_SESSION['UserAL'];
include($_SERVER["DOCUMENT_ROOT"] . "/inside/functions.php");
$check = "adv";
function doLang()
{
if ($tlang == 'en') {echo "Advanced Tutorials";}
if ($tlang == 'br') {echo "Tutoriais Avançados";}
if ($tlang == 'es') {echo "Tutoriales Avanzados";}
if ($tlang == 'fr') {echo "Tutos avancés";}
if ($tlang == 'id') {echo "Pelatihan dengan cara proffesional";}
if ($tlang == 'fi') {echo "Edistyneempiä oppaita";}
if ($tlang == 'tr') {echo "Gelişmiş Kılavuzlar";}
}
doLang();
echo "test".doLang()."test"; ?>
The "session" part is working correctly so I guess there ain’t no typo/problem there at all. So, basically, the doLang() function checks what language the user is using and then echos the ‘‘right’’ language, as you can see. If I use something like this:
<?
if ($tlang == 'en') {echo "Advanced Tutorials";}
if ($tlang == 'br') {echo "Tutoriais Avançados";}
if ($tlang == 'es') {echo "Tutoriales Avanzados";}
if ($tlang == 'fr') {echo "Tutos avancés";}
if ($tlang == 'id') {echo "Pelatihan dengan cara proffesional";}
if ($tlang == 'fi') {echo "Edistyneempiä oppaita";}
if ($tlang == 'tr') {echo "Gelişmiş Kılavuzlar";}
?>
It works like a charm but if I use a function instead it just doesn’t work. Am I missing something, did I do something wrong? Thanks for your attention!
returnthe value instead of echoing it.