title: PHP: Functions not working
body: <p>Good afternoon guys! I’ve been trying to call a function and it just doesn’t seem to work.</p>
  
  <p>So, this is the code I’ve got:</p>
  
  <pre><code>&lt;? 
  if (!isset($_SESSION)) session_start();
  $acess_level = 4;
  if (!isset($_SESSION['UserID']) OR ($_SESSION['UserAL'] &lt; $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"; ?&gt;
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>&lt;?
    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";}
  ?&gt;
  </code></pre>
  
  <p>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!</p>