How can PHP be used to include elements in a website without changing the URL in the address bar?

When including elements in a website using PHP, the URL in the address bar can remain unchanged by utilizing AJAX requests. This allows for dynamic content loading without refreshing the entire page. By sending an AJAX request to a PHP script that includes the desired elements, the content can be loaded seamlessly without affecting the URL displayed in the address bar.

<?php
if(isset($_POST['include_element'])) {
    $element = $_POST['include_element'];
    
    // Include the desired element based on the request
    include($element);
    exit;
}
?>