How can the use of variables like $dir in PHP includes be optimized for better code readability and maintainability?

To optimize the use of variables like $dir in PHP includes for better code readability and maintainability, it is recommended to define the variable at the beginning of the script with a clear and descriptive name. This will make it easier to understand the purpose of the variable and make changes if needed in the future.

<?php
$dir = "path/to/includes/";

include $dir . "header.php";
include $dir . "sidebar.php";
include $dir . "footer.php";
?>