I didn't code for years and I probably forgot everything, but I'm trying to start again to develop my personal website. I would like to put the div header and the div footer in a .php file so I don't have to manually modify every single page in case of modifications. My idea was like:
header-footer.php
<?php function head()
{echo '<ul>
<li><a href="tutorial.html"' if($current == "tutorial") {echo 'class="menu_link_active"';} else {echo 'class="menu_link"';} '>Tutorials</a></li>
<li><a href="contact.html"' if($current == "contact") {echo 'class="menu_link_active"';} else {echo 'class="menu_link"';} '>Contatti</a></li>
</ul>';}
function foot()
{echo '...html...';} ?>
The function head() should recognize the current page to highlight it. Then in the pages of my website I include the header-footer.php like this:
<head><?php include("php/header-footer.php"); ?><head>
Calling into the the two functions:
<body><?php $current = "projemi";
head();?>
...html code...
<?php foot(); ?></body>
My questions are: 1) the page displays this error: ----syntax error, unexpected 'if' (T_IF), expecting ',' or ';'---- and it referres to the head function. Where is the error? 2) Is it correct the process to obtain what I want or you would suggest something different?
Thanks you so much guys, and forgive me for my bad english!