How can the base href attribute be utilized in PHP to manage link URLs effectively?

When working with PHP, the base href attribute can be utilized to set a base URL for all relative links within a document. This is particularly useful when managing link URLs effectively, as it allows for easy maintenance and consistency across a website. By setting the base href attribute in the head section of a document, all relative links will be resolved based on this base URL.

<!DOCTYPE html>
<html>
<head>
    <base href="http://www.example.com/">
</head>
<body>
    <a href="page1.php">Page 1</a>
    <a href="page2.php">Page 2</a>
</body>
</html>