How can the use of $_GET variables in PHP be helpful when including files from different directories?

When including files from different directories in PHP, using $_GET variables can be helpful to dynamically specify the file path based on user input. This allows for more flexibility and customization in including files without hardcoding specific paths.

<?php
// Example of including files based on $_GET variable
if(isset($_GET['page'])) {
    $page = $_GET['page'];
    include("pages/{$page}.php");
} else {
    include("pages/home.php");
}
?>