Created index.php and style.php. I connected the style.php file to index.php. All imported variables work except for one, more precisely in one place, between title tags.

Previously, the main thing everything worked as created, and now it does not, what is the reason? Before that, I still set the variable for the header, but then I deleted it, and how I started to create a new variable, it was not displayed.

index.php

<? include("style.php"); //подлкючаем файл style.php $text="Программирование php"; $title="$index_tit"; ?> <!DOCTYPE html> <html> <head> <title><? print $title; ?></title> <!--css подключается как в html--> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php echo "<$h1 id='cent'>$logo</$h1> <$p>$text</$p> <$p>$menu</$p>"; //class, id подключаются в теге переменной как в html //в class, id используются апострифы ('') print(date('d F, Y')); //вывод даты на экран ?> </body> </html> 

style.php

 <?php //переменные для заголовков $index_tit="site"; //переменые для тегов $h1="h1"; $h2="h2"; $h3="h3"; $p="p"; $br="br"; $b="b"; $u="u"; $i="i"; $menu="<a href='tip_dannih.php'>типы данных</a>"; //ссылки главного меню $tip_dannih="<a href='tip_dannih1.php'>строковые значения 1</a> <a href='tip_dannih2.php'>массив</a>"; //название сайта $logo="PHP.RU"; ?> <!DOCTYPE html> <html> <head> <title><? print $title; ?></title> </head> </html> 
  • Code in the studio, please - Vitaly Kustov

3 answers 3

 <title><?php echo $title; ?></title> 

    The title is actually displayed, it will be enough to look at the source code that gives the browser and everything will fall into place.

    The first html from style.php is given to the browser, the title variable is not there, it is this empty title that the browser takes, after which it returns the html from index.php where it displays the title you need, but the browser already ignores it. it is already defined.

    And so define variables

      $title="$index_tit"; 

    it is not at all true

      Enable php short_open_tag in the settings, or use the variant from the first answer.