Sorry if this sounds stupid! I'm using PHP to create certain sections of my website like the header, then echoing them on to every page. The problem is I want to put some PHP code within the section like this:
<?php
function makeHeader () {
$menuContent = <<<MENU
<!DOCTYPE html>
<html> etc..........
<?php
if(isset($_SESSION['user']))
{
$user = isset($_SESSION['user']) ? $_SESSION['user'] : '';
echo "<a href='logout.php'>$user</a>";
}
else
{
echo "some text..";
}
?>
MENU;
$menuContent .= "\n";
return $menuContent;
}
?>
Is this possible? Its throwing up errors but starting from the if(isset($_SESSION['user'])) line rather than the line above it..