What are some common mistakes PHP beginners make when implementing navigation elements like page navigation?

One common mistake PHP beginners make when implementing navigation elements like page navigation is not properly handling the current page indicator. This can lead to confusion for users as they navigate through the website. To solve this issue, make sure to highlight the current page in the navigation bar by applying a different styling or class to the active link.

<?php
$current_page = basename($_SERVER['REQUEST_URI']);
?>

<ul>
    <li><a href="index.php" <?php if($current_page == 'index.php') echo 'class="active"'; ?>>Home</a></li>
    <li><a href="about.php" <?php if($current_page == 'about.php') echo 'class="active"'; ?>>About</a></li>
    <li><a href="services.php" <?php if($current_page == 'services.php') echo 'class="active"'; ?>>Services</a></li>
    <li><a href="contact.php" <?php if($current_page == 'contact.php') echo 'class="active"'; ?>>Contact</a></li>
</ul>