//Содержимое index.php <?php include('./header.html'); $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); echo $lang; if ($lang == 'ru') {include('./ru.php');} else {echo 'not ru';}; if ($lang == 'en') { include('./en.php');} else {echo 'not en';}; echo $langa; include('./footer.html'); ?> //содержимое ru.php <?php $langa = 'Russian'; ?> //содержимое en.php <?php $langa = 'English'; ?> 

Displays the contents of header.html and footer.html, and nothing between them. If I just include ('./ ru.php'), then it works, but I need to be envious of the condition. Even echo $ lang does not work, and if you remove conditional statements, it displays normally.

  • @ n.osennij why ../ru.php, if everything is in the same directory? - Daniel
  • @ n.osennij to make it clear to php that ru.php and en.php are in the same directory. - Daniel
  • Everything almost figured out. Commented out the line with the second conditional operator. Only not quite understood how it affects. - Daniel
  • in order of comment: if(in_array($lang, ['ru', 'en'])){ include "./{$lang}.php"; } if(in_array($lang, ['ru', 'en'])){ include "./{$lang}.php"; } (or || ) - teran
  • $ langa - who is this? Like the variable is called $ lang ... - labris

0