How can one ensure that links within an include file work properly in PHP?

When including files in PHP, the links within the included file may not work properly due to relative paths being different when included in different files. To ensure that links within an include file work properly, use absolute paths or define a base URL variable in the main file and use it to construct links in the included file.

<?php
// Define base URL variable in main file
$base_url = "http://www.example.com/";

// Include file with links
include 'included_file.php';
?>
```

```php
<!-- included_file.php -->
<a href="<?php echo $base_url; ?>page.php">Link</a>