I have a simple template created through my ClassPage. The class gets called and reads html code from a text file. Inside the navigation I want to echo a PHP variable but all I am getting is the embedded php commented out on the browser's console? I'm thinking perhaps the file that gets read isn't being processed by the server and that is why the php isn't being processed? Or I'm missing something really simple?
Heres the code: ClassPage -> getBody which gets the file called "superNav.txt". The string that gets returned is put together with the needed HTML head tags etc then outputted.
private function getBody() {
$text = "";
if ($this->specialUser) {
$text .= file_get_contents("Template/superNav.txt");
} else {
$text .= file_get_contents("Template/userNav.txt");
}
return $text;
}
This is the Text File:
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span id="glyph" class="glyphicon glyphicon-th-large"></span></button>
<a class="navbar-brand" href="#"><img alt="brand" id="brandLogo" src="Images/logo.png"></a>
<p id="navbarText" class="navbar-text">Webmin</p>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="welcome-super.php">Home</a></li>
<li><a href="view-rota.php">Rota</a></li>
<li><a href="rota-administration.php">Rota Admin</a></li>
<li><a href="user-administration.html">User Admin</a></li>
<li><a href="rota-archive.php">Archive</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="my-account.php"><span class="glyphicon glyphicon-user"></span><?php echo $user->getName(); ?></a></li>
<li><a href="#"><span class="glyphicon glyphicon-log-out"></span> Log Out</a></li>
</ul>
</div>
</div>
</nav>
This is the line that is giving me an issue:
<li><a href="my-account.php"><span class="glyphicon glyphicon-user"></span><?php echo $user->getName(); ?></a></li>
The php does not get shown to screen, the browsers console shows that the code is commented.
Any help is welcomed. Thanks in advance!