How can PHP developers ensure that their navigation links generate the correct virtual URLs for a website?

When generating navigation links in PHP, developers can ensure that the links generate the correct virtual URLs by using the `$_SERVER['REQUEST_URI']` variable to dynamically generate the links based on the current URL. This helps in creating links that are relative to the current page, ensuring that the navigation remains consistent across different pages on the website.

<?php
$current_url = $_SERVER['REQUEST_URI'];
echo '<a href="/home" class="' . ($current_url == '/home' ? 'active' : '') . '">Home</a>';
echo '<a href="/about" class="' . ($current_url == '/about' ? 'active' : '') . '">About</a>';
echo '<a href="/services" class="' . ($current_url == '/services' ? 'active' : '') . '">Services</a>';
?>