I am trying to write an IF statement so that when a user is on a certain page there will be additional content displayed. I have written this:
<?php
if (strpos($_SERVER['PHP_SELF'], 'about.php')){
<ul class="vertical-list">
<li><a href='/' class='button' onclick="return false;">Work Experience</a></li>
<li><a href='/' class='button' onclick="return false;">Education</a></li>
<li><a href='/' class='button' onclick="return false;">Skills</a></li>
<li><a href='/' class='button' onclick="return false;">Portfolio</a></li>
</ul>;
}
?>
So when a user is on the about page a navigation list will populate in the side bar but will be hidden if a user navigates away from the about page. The current code gives me this error:
Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\includes\sidebar.php on line 54
PHP’s
strposreturns a 0-base successful result, so you need to properly test for the “none found” result, AND you need to close and re-open your PHP tags: