How can the PHP code be refactored to improve readability and maintainability, especially in the context of generating HTML links?

The PHP code can be refactored by separating the logic for generating HTML links into a reusable function. This will improve readability and maintainability by encapsulating the link generation logic in one place, making it easier to update or modify in the future.

<?php

function generateLink($url, $text) {
    return "<a href='$url'>$text</a>";
}

// Example usage
$link1 = generateLink('https://www.example.com', 'Example Link');
$link2 = generateLink('https://www.google.com', 'Google Link');

echo $link1;
echo $link2;

?>