How can I modify the href attribute in PHP to link to an anchor ID?

To modify the href attribute in PHP to link to an anchor ID, you can concatenate the anchor ID to the URL using the '#' symbol. This will create a link that navigates to a specific section of the page defined by the anchor ID.

<?php
$anchor_id = "section1";
$url = "example.com/page.php";
$href = $url . "#" . $anchor_id;
echo "<a href='$href'>Link to Section 1</a>";
?>