How can PHP be used to dynamically load different content based on user interaction with a navigation bar?

To dynamically load different content based on user interaction with a navigation bar in PHP, you can use AJAX to asynchronously fetch and display content without reloading the entire page. This can be achieved by setting up event listeners on the navigation bar items that trigger AJAX requests to fetch the desired content from the server and then update the content area on the page.

<?php
if(isset($_GET['page'])) {
    $page = $_GET['page'];
    include($page . '.php');
} else {
    include('home.php');
}
?>